diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 52e9abf2fdda6d3cf4d0787c66321c263506e90c..4db3b263450ba2ea09e4e4e82b0e21962894e6a4 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1871,6 +1871,7 @@ add_executable(oaisim ${OPENAIR_TARGETS}/SIMU/USER/oaisim_functions.c ${OPENAIR_TARGETS}/SIMU/USER/event_handler.c ${OPENAIR_TARGETS}/SIMU/USER/oaisim.c + ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR2_DIR}/RRC/NAS/rb_config.c ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c @@ -1885,7 +1886,7 @@ add_executable(oaisim target_include_directories(oaisim PUBLIC ${OPENAIR_TARGETS}/SIMU/USER) target_link_libraries (oaisim - -Wl,--start-group + -Wl,-ldl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB GTPV1U SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS ${MSC_LIB} L2 ${RAL_LIB} LIB_NAS_UE SIMU SIMU_ETH SECU_OSA ${ITTI_LIB} ${MIH_LIB} -Wl,--end-group ) @@ -1916,6 +1917,7 @@ add_executable(oaisim_nos1 ${OPENAIR_TARGETS}/SIMU/USER/oaisim_functions.c ${OPENAIR_TARGETS}/SIMU/USER/event_handler.c ${OPENAIR_TARGETS}/SIMU/USER/oaisim.c + ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR2_DIR}/RRC/NAS/rb_config.c ${OPENAIR_TARGETS}/COMMON/create_tasks.c diff --git a/cmake_targets/autotests/v2/actions/execution_compile.bash b/cmake_targets/autotests/v2/actions/execution_compile.bash index 6791e93b0d678f9ab46ebbbe65f6a1e60701fe9a..530447ebcdb0f5639db86138d9f2bab0dc75b9ed 100644 --- a/cmake_targets/autotests/v2/actions/execution_compile.bash +++ b/cmake_targets/autotests/v2/actions/execution_compile.bash @@ -3,6 +3,9 @@ source oaienv cd cmake_targets rm -rf log mkdir -p log +echo $PRE_BUILD bash -c "$PRE_BUILD" +echo $BUILD_PROG $BUILD_ARGUMENTS $BUILD_PROG $BUILD_ARGUMENTS +echo $PRE_EXEC bash -c "$PRE_EXEC" diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index db0899d1fef9d0b68a1755ad22a1c389f0f95540..2272a338bef1ec8edb476ed657d9b5a2b6670712 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -418,9 +418,9 @@ function main() { if [ "$oaisim" = "1" ] ; then #to be discussed - # there is no RF device and no transport protocol + # there is no RF device transport protocol HW="None" - TP="None" + TP="ETHERNET" if [ "$XFORMS" == "True" ] ; then PRINT_STATS="True" @@ -671,6 +671,15 @@ function main() { # CMakeFiles/oai_nw_drv/oai_nw_drv.ko $dbin/oai_nw_drv.ko fi + if [ "$TP" == "ETHERNET" ] ; then + compilations \ + $oaisim_build_dir oai_eth_transpro \ + liboai_eth_transpro.so $dbin/liboai_eth_transpro.so.$REL + ln -s liboai_eth_transpro.so liboai_transpro.so + ln -s $dbin/liboai_eth_transpro.so.$REL $dbin/liboai_transpro.so + echo_info "liboai_transpro.so is linked with ETHERNET library" + fi + cmake_file=$DIR/oaisim_mme_build_oai/CMakeLists.txt cp $DIR/oaisim_mme_build_oai/CMakeLists.template $cmake_file echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 448d54f334db51dd3ce702312e94e90ca66f201e..f73078afc5e2a1be7075d520a4e5f5f0ed8685c5 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -171,7 +171,7 @@ install_protobuf_from_source(){ echo "Downloading protobuf" rm -rf /tmp/protobuf-2.6.1.tar.gz* /tmp/protobuf-2.6.1 wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz - tar -xzvf protobuf-2.6.1.tar.gz + tar -xzvf protobuf-2.6.1.tar.gz --owner $USER --group $USER --no-same-owner cd protobuf-2.6.1/ ./configure echo "Compiling protobuf" @@ -208,8 +208,8 @@ check_install_usrp_uhd_driver(){ #The new USRP repository $SUDO add-apt-repository ppa:ettusresearch/uhd -y $SUDO apt-get update - $SUDO apt-get -y install python python-tk libboost-all-dev libusb-1.0-0-dev - $SUDO apt-get -y install libuhd-dev libuhd003 uhd-host + $SUDO apt-get -y --allow-unauthenticated install python python-tk libboost-all-dev libusb-1.0-0-dev + $SUDO apt-get -y --allow-unauthenticated install libuhd-dev libuhd003 uhd-host } install_usrp_uhd_driver() { @@ -224,9 +224,9 @@ check_install_bladerf_driver(){ $SUDO add-apt-repository -y ppa:bladerf/bladerf $SUDO apt-get update fi - $SUDO apt-get install -y bladerf libbladerf-dev - $SUDO apt-get install -y bladerf-firmware-fx3 - $SUDO apt-get install -y bladerf-fpga-hostedx40 + $SUDO apt-get install -y--allow-unauthenticated bladerf libbladerf-dev + $SUDO apt-get install -y --allow-unauthenticated bladerf-firmware-fx3 + $SUDO apt-get install -y --allow-unauthenticated bladerf-fpga-hostedx40 } flash_firmware_bladerf() { diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index b262dbccf90de727c6af5aa173ed66684218ee3f..72f276408fd934376796230fcef038240e402f39 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -3831,6 +3831,8 @@ int generate_ue_dlsch_params_from_dci(int frame, LTE_UE_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; LTE_DL_UE_HARQ_t *dlsch0_harq,*dlsch1_harq; + if (!dlsch[0]) return -1; + #ifdef DEBUG_DCI LOG_D(PHY,"dci_tools.c: Filling ue dlsch params -> rnti %x, SFN/SF %d/%d, dci_format %s\n", rnti, @@ -7395,8 +7397,8 @@ int generate_eNB_ulsch_params_from_dci(PHY_VARS_eNB *eNB, rb_alloc = rballoc; if (rb_alloc>RIV_max) { - LOG_E(PHY,"Format 0: rb_alloc > RIV_max\n"); - mac_xface->macphy_exit("Format 0: rb_alloc > RIV_max\n"); + LOG_E(PHY,"Format 0: rb_alloc (%d) > RIV_max (%d)\n",rb_alloc,RIV_max); + mac_xface->macphy_exit("Format 0: error"); return(-1); } diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 924eef11b97a562a4fa7913b9db80ee54c63294e..be1bc6b08e27ed3b67bc111ad0c0357f4ad49083 100755 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -108,8 +108,8 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type (packet_type == IF4p5_PULTICK)){ db_fulllength = 12*fp->N_RB_UL; db_halflength = (db_fulllength)>>1; - slotoffsetF = 1; - blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength - 1; + slotoffsetF = 0; + blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength; if (subframe_select(fp,subframe)==SF_S) { nsym=fp->ul_symbols_in_S_subframe; @@ -131,10 +131,12 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type LOG_D(PHY,"IF4p5_PULFFT: frame %d, subframe %d, symbol %d\n",frame,subframe,symbol_id); for (element_id=0; element_id<db_halflength; element_id++) { i = (uint16_t*) &rxdataF[0][blockoffsetF+element_id]; - data_block[element_id] = ((uint16_t) lin2alaw[*i]) | (lin2alaw[*(i+1)]<<8); + data_block[element_id] = ((uint16_t) lin2alaw[*i]) | ((uint16_t)(lin2alaw[*(i+1)]<<8)); i = (uint16_t*) &rxdataF[0][slotoffsetF+element_id]; - data_block[element_id+db_halflength] = ((uint16_t) lin2alaw[*i]) | (lin2alaw[*(i+1)]<<8); + data_block[element_id+db_halflength] = ((uint16_t) lin2alaw[*i]) | ((uint16_t)(lin2alaw[*(i+1)]<<8)); + //if (element_id==0) LOG_I(PHY,"send_if4p5: symbol %d rxdata0 = (%d,%d)\n",symbol_id,*i,*(i+1)); + } packet_header->frame_status &= ~(0x000f<<26); @@ -235,7 +237,7 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t 0) < 0) { perror("ETHERNET read"); } - + if (eth->flags == ETH_RAW_IF4p5_MODE) { packet_header = (IF4p5_header_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES); data_block = (uint16_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES+sizeof_IF4p5_header_t); @@ -251,7 +253,6 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t *packet_type = packet_header->sub_type; - if (*packet_type == IF4p5_PDLFFT) { *symbol_number = ((packet_header->frame_status)>>26)&0x000f; @@ -273,10 +274,10 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t } else if (*packet_type == IF4p5_PULFFT) { *symbol_number = ((packet_header->frame_status)>>26)&0x000f; - if (eNB->CC_id==1) LOG_I(PHY,"UL_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe,*symbol_number); + if (eNB->CC_id==0) LOG_D(PHY,"UL_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe,*symbol_number); - slotoffsetF = (*symbol_number)*(fp->ofdm_symbol_size) + 1; - blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength - 1; + slotoffsetF = (*symbol_number)*(fp->ofdm_symbol_size); + blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength; for (element_id=0; element_id<db_halflength; element_id++) { i = (uint16_t*) &rxdataF[0][blockoffsetF+element_id]; @@ -286,9 +287,12 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t i = (uint16_t*) &rxdataF[0][slotoffsetF+element_id]; *i = alaw2lin[ (data_block[element_id+db_halflength] & 0xff) ]; *(i+1) = alaw2lin[ (data_block[element_id+db_halflength]>>8) ]; + + //if (element_id==0) LOG_I(PHY,"recv_if4p5: symbol %d rxdata0 = (%u,%u)\n",*symbol_number,*i,*(i+1)); } - } else if (*packet_type == IF4p5_PRACH) { + } else if (*packet_type == IF4p5_PRACH) { + LOG_D(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe); if (eNB->CC_id==1) LOG_I(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe); // FIX: hard coded prach samples length diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c index 489fdb0f71dae676914243a7d93c2ed59f4eb8eb..1555162cb49fbcc5f27c355f655c9909d2d4d728 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach.c +++ b/openair1/PHY/LTE_TRANSPORT/prach.c @@ -645,6 +645,12 @@ int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint1 #else //normal case (simulation) prach_start = subframe*ue->frame_parms.samples_per_tti-ue->N_TA_offset; + LOG_D(PHY,"[UE %d] prach_start %d, rx_offset %d, hw_timing_advance %d, N_TA_offset %d\n", ue->Mod_id, + prach_start, + ue->rx_offset, + ue->hw_timing_advance, + ue->N_TA_offset); + #endif @@ -1074,6 +1080,8 @@ int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint1 #ifdef PRACH_DEBUG write_output("prach_txF0.m","prachtxF0",prachF,prach_len-Ncp,1,1); write_output("prach_tx0.m","prachtx0",prach+(Ncp<<1),prach_len-Ncp,1,1); + write_output("txsig.m","txs",(int16_t*)(&ue->common_vars.txdata[0][0]),2*ue->frame_parms.samples_per_tti,1,1); + exit(-1); #endif return signal_energy( (int*)prach, 256 ); @@ -1125,7 +1133,7 @@ void rx_prach(PHY_VARS_eNB *eNB, int fft_size,log2_ifft_size; uint8_t nb_ant_rx = 1; //eNB->frame_parms.nb_antennas_rx; - // int en; + int en; for (aa=0; aa<nb_ant_rx; aa++) { prach[aa] = (int16_t*)&eNB->common_vars.rxdata[0][aa][subframe*eNB->frame_parms.samples_per_tti-eNB->N_TA_offset]; @@ -1327,9 +1335,26 @@ void rx_prach(PHY_VARS_eNB *eNB, /// **** send_IF4 of rxsigF to RCC **** /// send_IF4p5(eNB, eNB->proc.frame_prach, eNB->proc.subframe_prach, IF4p5_PRACH, k); - // en = dB_fixed(signal_energy(&rxsigF[0][k],840)); - // if (en>60) - // printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en); +#if 0 + /* TODO: resolv this conflict (there should be no printf anyway, so no big deal) */ +<<<<<<< HEAD + /* + en = dB_fixed(signal_energy(&rxsigF[0][k],840)); + printf("Sending PRACH, k %d,n_ra_prb %d, N_RB_UL %d, en %d\n",k,n_ra_prb,eNB->frame_parms.N_RB_UL,en); + if (en>60) { + printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en); + write_output("prach_rx0.m","prach_rx0",(int16_t*)&rxsigF[0][k],839,1,1); + exit(-1); + } + */ + +======= + en = dB_fixed(signal_energy(&rxsigF[0][k],840)); + if (en>60) + printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en); +>>>>>>> origin/fix-if4p5 +#endif + return; } else if (eNB->node_function == NGFI_RCC_IF4p5) { k = (12*n_ra_prb) - 6*eNB->frame_parms.N_RB_UL; @@ -1347,9 +1372,25 @@ void rx_prach(PHY_VARS_eNB *eNB, (&rxsigF[0][0]), 839*2*sizeof(int16_t)); - //en = dB_fixed(signal_energy(&rxsigF[0][k],840)); - // if (en>60) - //printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en); +#if 0 + /* TODO: resolv this conflict (there should be no printf anyway, so no big deal) */ +<<<<<<< HEAD + /* + en = dB_fixed(signal_energy(&rxsigF[0][k],840)); + printf("Receiving PRACH, k %d,n_ra_prb %d, N_RB_UL %d, en %d\n",k,n_ra_prb,eNB->frame_parms.N_RB_UL,en); + if (en>60) { + printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en); + write_output("prach_rx0.m","prach_rx0",(int16_t*)&rxsigF[0][k],839,1,1); + exit(-1); + } + */ +======= + en = dB_fixed(signal_energy(&rxsigF[0][k],840)); + /*if (en>60) + printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);*/ + +>>>>>>> origin/fix-if4p5 +#endif } @@ -1523,7 +1564,7 @@ void rx_prach(PHY_VARS_eNB *eNB, #ifdef PRACH_DEBUG - // if (en>40) { + if (en>40) { k = (12*n_ra_prb) - 6*eNB->frame_parms.N_RB_UL; if (k<0) @@ -1537,7 +1578,7 @@ void rx_prach(PHY_VARS_eNB *eNB, write_output("prach_rxF_comp0.m","prach_rxF_comp0",prachF,1024,1,1); write_output("prach_ifft0.m","prach_t0",prach_ifft[0],1024,1,1); exit(-1); - // } + } #endif } // new dft @@ -1551,7 +1592,7 @@ void rx_prach(PHY_VARS_eNB *eNB, for (aa=0; aa<nb_ant_rx; aa++) { lev += (int32_t)prach_ifft[aa][(preamble_shift2+i)<<1]*prach_ifft[aa][(preamble_shift2+i)<<1] + (int32_t)prach_ifft[aa][1+((preamble_shift2+i)<<1)]*prach_ifft[aa][1+((preamble_shift2+i)<<1)]; } - + levdB = dB_fixed_times10(lev); if (levdB>preamble_energy_list[preamble_index] ) { @@ -1559,12 +1600,12 @@ void rx_prach(PHY_VARS_eNB *eNB, preamble_delay_list[preamble_index] = (i*fft_size)>>log2_ifft_size; } } - #ifdef PRACH_DEBUG LOG_D(PHY,"[RAPROC] Preamble %d => %d dB, %d (shift %d (%d), NCS2 %d(%d), Ncp %d)\n",preamble_index,preamble_energy_list[preamble_index],preamble_delay_list[preamble_index],preamble_shift2, preamble_shift, NCS2,NCS,Ncp); -#endif // exit(-1); +#endif + }// preamble_index stop_meas(&eNB->rx_prach); diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c index ee9bfc53cdd431c2fb7770914f6dcfe3091be058..a4bcd802f5c7551a646aa025fd559f1b8f6ec3d7 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c @@ -415,7 +415,7 @@ void ulsch_modulation(int32_t **txdataF, return; } - if (first_rb >25 ) { + if (first_rb > frame_parms->N_RB_UL) { printf("ulsch_modulation.c: Frame %d, Subframe %d Illegal first_rb %d\n",frame,subframe,first_rb); return; } diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index d210f5c57462d46b87fbf9950343773af8c7ac15..2997926b92c387b83ce68a3439ae6145ab06c36c 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -434,6 +434,7 @@ typedef struct PHY_VARS_eNB_s { eNB_proc_t proc; eNB_func_t node_function; eNB_timing_t node_timing; + eth_params_t *eth_params; int single_thread_flag; openair0_rf_map rf_map; int abstraction_flag; diff --git a/openair1/SCHED/phy_mac_stub.c b/openair1/SCHED/phy_mac_stub.c index cb22461656851884d7b3a0157974d5e4580edc67..9a41ae09c52378daf4a514296a3b64bb15afd974 100644 --- a/openair1/SCHED/phy_mac_stub.c +++ b/openair1/SCHED/phy_mac_stub.c @@ -455,6 +455,151 @@ void fill_dci(DCI_PDU *DCI_pdu,PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) break; } + + + + + DCI_pdu->dci_alloc[1].L = 2; + DCI_pdu->dci_alloc[1].rnti = 0x1235; + DCI_pdu->dci_alloc[1].format = format0; + DCI_pdu->dci_alloc[1].ra_flag = 0; + + if (eNB->frame_parms.frame_type == FDD) { + switch (eNB->frame_parms.N_RB_DL) { + case 6: + ((DCI0_1_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->type = 0; + ((DCI0_1_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->hopping = 0; + ((DCI0_1_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->rballoc = computeRIV(6,1,4); + ((DCI0_1_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->mcs = eNB->target_ue_ul_mcs; + ((DCI0_1_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->ndi = proc->frame_tx&1; + ((DCI0_1_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->TPC = 0; + ((DCI0_1_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cshift = 0; + ((DCI0_1_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cqi_req = 1; + break; + /* case 15: + ((DCI0_3MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->type = 0; + ((DCI0_3MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->hopping = 0; + ((DCI0_3MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->rballoc = computeRIV(25,2,eNB->ue_ul_nb_rb); + ((DCI0_3MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->mcs = eNB->target_ue_ul_mcs; + ((DCI0_3MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->ndi = proc->frame_tx&1; + ((DCI0_3MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->TPC = 0; + ((DCI0_3MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cshift = 0; + ((DCI0_3MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->dai = 0; + ((DCI0_3MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cqi_req = 1; + break;*/ + case 25: + ((DCI0_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->type = 0; + ((DCI0_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->hopping = 0; + ((DCI0_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->rballoc = computeRIV(25,1,20); + printf("rballoc %d\n",((DCI0_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->rballoc); + ((DCI0_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->mcs = eNB->target_ue_ul_mcs; + ((DCI0_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->ndi = proc->frame_tx&1; + ((DCI0_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->TPC = 0; + ((DCI0_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cshift = 0; + ((DCI0_5MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cqi_req = 1; + break; + case 50: + ((DCI0_10MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->type = 0; + ((DCI0_10MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->hopping = 0; + ((DCI0_10MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->rballoc = computeRIV(50,1,48); + ((DCI0_10MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->mcs = eNB->target_ue_ul_mcs; + ((DCI0_10MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->ndi = proc->frame_tx&1; + ((DCI0_10MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->TPC = 0; + ((DCI0_10MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cshift = 0; + ((DCI0_10MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cqi_req = 1; + break; + /* case 75: + ((DCI0_15MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->type = 0; + ((DCI0_15MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->hopping = 0; + ((DCI0_15MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->rballoc = computeRIV(25,2,eNB->ue_ul_nb_rb); + ((DCI0_15MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->mcs = eNB->target_ue_ul_mcs; + ((DCI0_15MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->ndi = proc->frame_tx&1; + ((DCI0_15MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->TPC = 0; + ((DCI0_15MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cshift = 0; + ((DCI0_15MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cqi_req = 1; + break;*/ + case 100: + ((DCI0_20MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->type = 0; + ((DCI0_20MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->hopping = 0; + ((DCI0_20MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->rballoc = computeRIV(100,1,96); + ((DCI0_20MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->mcs = eNB->target_ue_ul_mcs; + ((DCI0_20MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->ndi = proc->frame_tx&1; + ((DCI0_20MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->TPC = 0; + ((DCI0_20MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cshift = 0; + ((DCI0_20MHz_FDD_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cqi_req = 1; + break; + } + } + else { + switch (eNB->frame_parms.N_RB_DL==6) { + case 6: + ((DCI0_1_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->type = 0; + ((DCI0_1_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->hopping = 0; + ((DCI0_1_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->rballoc = computeRIV(6,1,5); + ((DCI0_1_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->mcs = eNB->target_ue_ul_mcs; + ((DCI0_1_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->ndi = proc->frame_tx&1; + ((DCI0_1_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->TPC = 0; + ((DCI0_1_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cshift = 0; + ((DCI0_1_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->dai = 0; + ((DCI0_1_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cqi_req = 1; + break; + /* case 15: + ((DCI0_3MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->type = 0; + ((DCI0_3MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->hopping = 0; + ((DCI0_3MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->rballoc = computeRIV(25,2,eNB->ue_ul_nb_rb); + ((DCI0_3MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->mcs = eNB->target_ue_ul_mcs; + ((DCI0_3MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->ndi = proc->frame_tx&1; + ((DCI0_3MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->TPC = 0; + ((DCI0_3MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cshift = 0; + ((DCI0_3MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->dai = 0; + ((DCI0_3MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cqi_req = 1; + break;*/ + case 25: + ((DCI0_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->type = 0; + ((DCI0_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->hopping = 0; + ((DCI0_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->rballoc = computeRIV(25,2,20); + ((DCI0_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->mcs = eNB->target_ue_ul_mcs; + ((DCI0_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->ndi = proc->frame_tx&1; + ((DCI0_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->TPC = 0; + ((DCI0_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cshift = 0; + ((DCI0_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->dai = 0; + ((DCI0_5MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cqi_req = 1; + break; + case 50: + ((DCI0_10MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->type = 0; + ((DCI0_10MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->hopping = 0; + ((DCI0_10MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->rballoc = computeRIV(50,1,48); + ((DCI0_10MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->mcs = eNB->target_ue_ul_mcs; + ((DCI0_10MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->ndi = proc->frame_tx&1; + ((DCI0_10MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->TPC = 0; + ((DCI0_10MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cshift = 0; + ((DCI0_10MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->dai = 0; + ((DCI0_10MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cqi_req = 1; + break; + /* case 75: + ((DCI0_15MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->type = 0; + ((DCI0_15MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->hopping = 0; + ((DCI0_15MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->rballoc = computeRIV(25,2,eNB->ue_ul_nb_rb); + ((DCI0_15MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->mcs = eNB->target_ue_ul_mcs; + ((DCI0_15MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->ndi = proc->frame_tx&1; + ((DCI0_15MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->TPC = 0; + ((DCI0_15MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cshift = 0; + ((DCI0_15MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->dai = 0; + ((DCI0_15MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cqi_req = 1; + break;*/ + case 100: + ((DCI0_20MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->type = 0; + ((DCI0_20MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->hopping = 0; + ((DCI0_20MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->rballoc = computeRIV(100,1,96); + ((DCI0_20MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->mcs = eNB->target_ue_ul_mcs; + ((DCI0_20MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->ndi = proc->frame_tx&1; + ((DCI0_20MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->TPC = 0; + ((DCI0_20MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cshift = 0; + ((DCI0_20MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->dai = 0; + ((DCI0_20MHz_TDD_1_6_t*)&DCI_pdu->dci_alloc[1].dci_pdu[0])->cqi_req = 1; + break; + } + } } else if (transmission_mode==4) { DCI_pdu->Num_ue_spec_dci = 1; // user 1 @@ -543,32 +688,8 @@ void fill_dci(DCI_PDU *DCI_pdu,PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) memcpy((void*)&DCI_pdu->dci_alloc[0].dci_pdu[0],&RA_alloc_pdu,sizeof(DCI1A_5MHz_TDD_1_6_t)); break; */ - /* - case 9: - DCI_pdu->Num_ue_spec_dci = 1; + - //user 1 - if (eNB->frame_parms.frame_type == FDD) - DCI_pdu->dci_alloc[0].dci_length = sizeof_DCI0_5MHz_FDD_t ; - else - DCI_pdu->dci_alloc[0].dci_length = sizeof_DCI0_5MHz_TDD_1_6_t ; - - DCI_pdu->dci_alloc[0].L = 2; - DCI_pdu->dci_alloc[0].rnti = 0x1235; - DCI_pdu->dci_alloc[0].format = format0; - DCI_pdu->dci_alloc[0].ra_flag = 0; - - UL_alloc_pdu.type = 0; - UL_alloc_pdu.hopping = 0; - UL_alloc_pdu.rballoc = computeRIV(25,2,eNB->ue_ul_nb_rb); - UL_alloc_pdu.mcs = eNB->target_ue_ul_mcs; - UL_alloc_pdu.ndi = proc->frame_tx&1; - UL_alloc_pdu.TPC = 0; - UL_alloc_pdu.cshift = 0; - UL_alloc_pdu.dai = 0; - UL_alloc_pdu.cqi_req = 1; - memcpy((void*)&DCI_pdu->dci_alloc[0].dci_pdu[0],(void *)&UL_alloc_pdu,sizeof(DCI0_5MHz_TDD_1_6_t)); - */ // user 2 /* DCI_pdu->dci_alloc[1].dci_length = sizeof_DCI0_5MHz_TDD_1_6_t ; @@ -593,11 +714,8 @@ void fill_dci(DCI_PDU *DCI_pdu,PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) UL_alloc_pdu.dai = 0; UL_alloc_pdu.cqi_req = 1; memcpy((void*)&DCI_pdu->dci_alloc[1].dci_pdu[0],(void *)&UL_alloc_pdu,sizeof(DCI0_5MHz_TDD_1_6_t)); - break; + */ - - /*default: - break;*/ } /* diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index b47651b873d2f6ba8f81158bbb24c19da24157a6..669766eee9e4fa12c5126126912d39f3dee831f8 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -92,6 +92,9 @@ extern uint16_t hundred_times_log10_NPRB[100]; unsigned int max_peak_val; int max_sync_pos; +int harq_pid_updated[NUMBER_OF_UE_MAX][8] = {{0}}; +int harq_pid_round[NUMBER_OF_UE_MAX][8] = {{0}}; + //DCI_ALLOC_t dci_alloc[8]; #ifdef EMOS @@ -1444,15 +1447,6 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, eNB->dlsch_ra->active = 0; } -#if defined(FLEXRAN_AGENT_SB_IF) -#ifndef DISABLE_SF_TRIGGER - //Send subframe trigger to the controller - if (mac_agent_registered[eNB->Mod_id]) { - agent_mac_xface[eNB->Mod_id]->flexran_agent_send_sf_trigger(eNB->Mod_id); - } -#endif -#endif - // Now scan UE specific DLSCH for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { @@ -1553,7 +1547,6 @@ void process_HARQ_feedback(uint8_t UE_id, int subframe = proc->subframe_rx; int harq_pid = subframe2harq_pid( fp,frame,subframe); - if (fp->frame_type == FDD) { //FDD subframe_m4 = (subframe<4) ? subframe+6 : subframe-4; @@ -1681,6 +1674,7 @@ void process_HARQ_feedback(uint8_t UE_id, mp = m; dl_harq_pid[m] = dlsch->harq_ids[dl_subframe]; + harq_pid_updated[UE_id][dl_harq_pid[m]] = 1; if ((pucch_sel != 2)&&(pusch_flag == 0)) { // multiplexing if ((SR_payload == 1)&&(all_ACKed == 1)) @@ -1768,7 +1762,7 @@ void process_HARQ_feedback(uint8_t UE_id, eNB->dlsch[(uint8_t)UE_id][0]->harq_processes[dl_harq_pid[m]]->TBS; */ } - + // Do fine-grain rate-adaptation for DLSCH if (ue_stats->dlsch_NAK_round0 > dlsch->error_threshold) { if (ue_stats->dlsch_mcs_offset == 1) @@ -1781,7 +1775,7 @@ void process_HARQ_feedback(uint8_t UE_id, LOG_D(PHY,"[process_HARQ_feedback] Frame %d Setting round to %d for pid %d (subframe %d)\n",frame, dlsch_harq_proc->round,dl_harq_pid[m],subframe); #endif - + harq_pid_round[UE_id][dl_harq_pid[m]] = dlsch_harq_proc->round; // Clear NAK stats and adjust mcs offset // after measurement window timer expires if (ue_stats->dlsch_sliding_cnt == dlsch->ra_window_size) { @@ -1800,8 +1794,6 @@ void process_HARQ_feedback(uint8_t UE_id, ue_stats->dlsch_NAK_round0 = 0; ue_stats->dlsch_sliding_cnt = 0; } - - } } } @@ -2751,6 +2743,7 @@ void eNB_fep_full(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc_rxtx) { if (eNB->node_function == NGFI_RRU_IF4p5) { /// **** send_IF4 of rxdataF to RCC (no prach now) **** /// + LOG_D(PHY,"send_IF4p5 (PULFFT): frame %d, subframe %d\n",proc_rxtx->frame_rx,proc_rxtx->subframe_rx); send_IF4p5(eNB, proc_rxtx->frame_rx, proc_rxtx->subframe_rx, IF4p5_PULFFT, 0); } } @@ -3071,12 +3064,15 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const LOG_D(PHY,"[eNB][PUSCH %d] Increasing to round %d\n",harq_pid,eNB->ulsch[i]->harq_processes[harq_pid]->round); if (eNB->ulsch[i]->Msg3_flag == 1) { + LOG_D(PHY,"[eNB %d/%d][RAPROC] frame %d, subframe %d, UE %d: Error receiving ULSCH (Msg3), round %d/%d\n", eNB->Mod_id, eNB->CC_id, frame,subframe, i, eNB->ulsch[i]->harq_processes[harq_pid]->round-1, fp->maxHARQ_Msg3Tx-1); + /*dump_ulsch(eNB,proc,i); + exit(-1);*/ LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d RNTI %x RX power (%d,%d) RSSI (%d,%d) N0 (%d,%d) dB ACK (%d,%d), decoding iter %d\n", eNB->Mod_id,harq_pid, @@ -3159,6 +3155,10 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const eNB->UE_stats[i].ulsch_errors[harq_pid]++; eNB->UE_stats[i].ulsch_consecutive_errors++; + /*if (eNB->ulsch[i]->harq_processes[harq_pid]->nb_rb > 20) { + dump_ulsch(eNB,proc,i); + exit(-1); + }*/ // indicate error to MAC if (eNB->mac_enabled == 1) mac_xface->rx_sdu(eNB->Mod_id, @@ -3423,14 +3423,21 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const } #endif - - //} #ifdef EMOS phy_procedures_emos_eNB_RX(subframe,eNB); #endif +#if defined(FLEXRAN_AGENT_SB_IF) +#ifndef DISABLE_SF_TRIGGER + //Send subframe trigger to the controller + if (mac_agent_registered[eNB->Mod_id]) { + agent_mac_xface[eNB->Mod_id]->flexran_agent_send_sf_trigger(eNB->Mod_id); + } +#endif +#endif + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_UESPEC+offset, 0 ); stop_meas(&eNB->phy_proc_rx); diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index ac90094ea495f588e5e1b375126dd15460b87562..e061effadb44f487baea3e8e2f5c4458b26f7dea 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -2188,11 +2188,12 @@ void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,ui subframe_tx, ue->ulsch[eNB_id]->o_ACK); - reset_ack(&ue->frame_parms, - ue->dlsch_SI[eNB_id]->harq_ack, - subframe_tx, - ue->ulsch[eNB_id]->o_ACK); - + if (ue->dlsch_SI[eNB_id]) + reset_ack(&ue->frame_parms, + ue->dlsch_SI[eNB_id]->harq_ack, + subframe_tx, + ue->ulsch[eNB_id]->o_ACK); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); stop_meas(&ue->phy_proc_tx); @@ -2605,19 +2606,19 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin #endif } else { - /* + LOG_E(PHY,"[UE %d] frame %d, subframe %d, Error decoding PBCH!\n", ue->Mod_id,frame_rx, subframe_rx); - + /* LOG_I(PHY,"[UE %d] rx_offset %d\n",ue->Mod_id,ue->rx_offset); write_output("rxsig0.m","rxs0", ue->common_vars.rxdata[0],ue->frame_parms.samples_per_tti,1,1); - write_output("H00.m","h00",&(ue->common_vars.dl_ch_estimates[0][0][0]),((ue->frame_parms.Ncp==0)?7:6)*(ue->frame_parms.ofdm_symbol_size),1,1); - write_output("H10.m","h10",&(ue->common_vars.dl_ch_estimates[0][2][0]),((ue->frame_parms.Ncp==0)?7:6)*(ue->frame_parms.ofdm_symbol_size),1,1); + write_output("H00.m","h00",&(ue->common_vars.common_vars_rx_data_per_thread[0].dl_ch_estimates[0][0][0]),((ue->frame_parms.Ncp==0)?7:6)*(ue->frame_parms.ofdm_symbol_size),1,1); + write_output("H10.m","h10",&(ue->common_vars.common_vars_rx_data_per_thread[0].dl_ch_estimates[0][2][0]),((ue->frame_parms.Ncp==0)?7:6)*(ue->frame_parms.ofdm_symbol_size),1,1); - write_output("rxsigF0.m","rxsF0", ue->common_vars.rxdataF[0],8*ue->frame_parms.ofdm_symbol_size,1,1); + write_output("rxsigF0.m","rxsF0", ue->common_vars.common_vars_rx_data_per_thread[0].rxdataF[0],8*ue->frame_parms.ofdm_symbol_size,1,1); write_output("PBCH_rxF0_ext.m","pbch0_ext",ue->pbch_vars[0]->rxdataF_ext[0],12*4*6,1,1); write_output("PBCH_rxF0_comp.m","pbch0_comp",ue->pbch_vars[0]->rxdataF_comp[0],12*4*6,1,1); write_output("PBCH_rxF_llr.m","pbch_llr",ue->pbch_vars[0]->llr,(ue->frame_parms.Ncp==0) ? 1920 : 1728,1,4); @@ -2969,17 +2970,14 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint #endif } - } else if( (dci_alloc_rx[i].rnti == ue->ulsch[eNB_id]->cba_rnti[0]) && + } + /* else if( (dci_alloc_rx[i].rnti == ue->ulsch[eNB_id]->cba_rnti[0]) && (dci_alloc_rx[i].format == format0)) { // UE could belong to more than one CBA group // ue->Mod_id%ue->ulsch[eNB_id]->num_active_cba_groups] #ifdef DEBUG_PHY_PROC LOG_D(PHY,"[UE %d][PUSCH] Frame %d subframe %d: Found cba rnti %x, format 0, dci_cnt %d\n", ue->Mod_id,frame_rx,subframe_rx,dci_alloc_rx[i].rnti,i); - /* - if (((frame_rx%100) == 0) || (frame_rx < 20)) - dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); - */ #endif ue->ulsch_no_allocation_counter[eNB_id] = 0; @@ -3003,9 +3001,8 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint LOG_D(PHY,"[UE %d] Generate UE ULSCH CBA_RNTI format 0 (subframe %d)\n",ue->Mod_id,subframe_rx); #endif ue->ulsch[eNB_id]->num_cba_dci[(subframe_rx+4)%10]++; - } - } - + } + */ else { #ifdef DEBUG_PHY_PROC LOG_D(PHY,"[UE %d] frame %d, subframe %d: received DCI %d with RNTI=%x (C-RNTI:%x, CBA_RNTI %x) and format %d!\n",ue->Mod_id,frame_rx,subframe_rx,i,dci_alloc_rx[i].rnti, diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index e353f5fde72d65725154084e1520cec23bb1e6b7..1a43f203df6b918888981298cda34684e770914e 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -443,14 +443,14 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, if (rlc_reports[j] == NULL) goto error; protocol__flex_rlc_bsr__init(rlc_reports[j]); - rlc_reports[j]->lc_id = j+1; + rlc_reports[j]->lc_id = j + 1; rlc_reports[j]->has_lc_id = 1; - rlc_reports[j]->tx_queue_size = flexran_get_tx_queue_size(enb_id,i,j+1); + rlc_reports[j]->tx_queue_size = flexran_get_tx_queue_size(enb_id,i,j + 1); rlc_reports[j]->has_tx_queue_size = 1; - + //TODO:Set tx queue head of line delay in ms - rlc_reports[j]->tx_queue_hol_delay = 100; - rlc_reports[j]->has_tx_queue_hol_delay = 0; + rlc_reports[j]->tx_queue_hol_delay = flexran_get_hol_delay(enb_id, i, j+1); + rlc_reports[j]->has_tx_queue_hol_delay = 1; //TODO:Set retransmission queue size in bytes rlc_reports[j]->retransmission_queue_size = 10; rlc_reports[j]->has_retransmission_queue_size = 0; @@ -657,6 +657,8 @@ int flexran_agent_mac_stats_reply(mid_t mod_id, full_ul_report->pucch_dbm[j]->p0_pucch_dbm = flexran_get_p0_pucch_dbm(enb_id,i,j); full_ul_report->pucch_dbm[j]->has_p0_pucch_dbm = 1; } + full_ul_report->pucch_dbm[j]->has_p0_pucch_updated = 1; + full_ul_report->pucch_dbm[j]->p0_pucch_updated = flexran_get_p0_pucch_status(enb_id, i, j); } //Add full UL CQI report to the UE report @@ -921,9 +923,13 @@ int flexran_agent_mac_destroy_sr_info(Protocol__FlexranMessage *msg) { int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) { Protocol__FlexHeader *header; - int i,j; + int i, j, UE_id; + + int available_harq[NUMBER_OF_UE_MAX]; + const int xid = *((int *)params); + Protocol__FlexSfTrigger *sf_trigger_msg; sf_trigger_msg = malloc(sizeof(Protocol__FlexSfTrigger)); if (sf_trigger_msg == NULL) { @@ -937,29 +943,47 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle frame_t frame; sub_frame_t subframe; - int ahead_of_time = 1; + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + available_harq[i] = -1; + } + + int ahead_of_time = 0; frame = (frame_t) flexran_get_current_system_frame_num(mod_id); subframe = (sub_frame_t) flexran_get_current_subframe(mod_id); subframe = ((subframe + ahead_of_time) % 10); - - int full_frames_ahead = ((ahead_of_time / 10) % 10); - frame = frame + full_frames_ahead; - if (subframe < flexran_get_current_subframe(mod_id)) { - frame++; + frame = (frame + 1) % 1024; } + int additional_frames = ahead_of_time / 10; + frame = (frame + additional_frames) % 1024; + sf_trigger_msg->header = header; sf_trigger_msg->has_sfn_sf = 1; - sf_trigger_msg->sfn_sf = flexran_get_future_sfn_sf(mod_id, 1); + sf_trigger_msg->sfn_sf = flexran_get_future_sfn_sf(mod_id, 3); + + sf_trigger_msg->n_dl_info = 0; + + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (j = 0; j < 8; j++) { + if (harq_pid_updated[i][j] == 1) { + available_harq[i] = j; + sf_trigger_msg->n_dl_info++; + break; + } + } + } + + + // LOG_I(FLEXRAN_AGENT, "Sending subframe trigger for frame %d and subframe %d\n", flexran_get_current_frame(mod_id), (flexran_get_current_subframe(mod_id) + 1) % 10); /*TODO: Fill in the number of dl HARQ related info, based on the number of currently *transmitting UEs */ - sf_trigger_msg->n_dl_info = flexran_get_num_ues(mod_id); + // sf_trigger_msg->n_dl_info = flexran_get_num_ues(mod_id); Protocol__FlexDlInfo **dl_info = NULL; @@ -967,29 +991,39 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle dl_info = malloc(sizeof(Protocol__FlexDlInfo *) * sf_trigger_msg->n_dl_info); if(dl_info == NULL) goto error; + i = -1; //Fill the status of the current HARQ process for each UE - for(i = 0; i < sf_trigger_msg->n_dl_info; i++) { + for(UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (available_harq[UE_id] < 0) { + continue; + } else { + i++; + } dl_info[i] = malloc(sizeof(Protocol__FlexDlInfo)); if(dl_info[i] == NULL) goto error; protocol__flex_dl_info__init(dl_info[i]); - dl_info[i]->rnti = flexran_get_ue_crnti(mod_id, i); + dl_info[i]->rnti = flexran_get_ue_crnti(mod_id, UE_id); dl_info[i]->has_rnti = 1; /*Fill in the right id of this round's HARQ process for this UE*/ - unsigned char harq_id; - unsigned char harq_status; - flexran_get_harq(mod_id, UE_PCCID(mod_id,i), i, frame, subframe, &harq_id, &harq_status); - dl_info[i]->harq_process_id = harq_id; + // uint8_t harq_id; + //uint8_t harq_status; + // flexran_get_harq(mod_id, UE_PCCID(mod_id,i), i, frame, subframe, &harq_id, &harq_status); + + + dl_info[i]->harq_process_id = available_harq[UE_id]; + harq_pid_updated[UE_id][available_harq[UE_id]] = 0; dl_info[i]->has_harq_process_id = 1; /* Fill in the status of the HARQ process (2 TBs)*/ dl_info[i]->n_harq_status = 2; dl_info[i]->harq_status = malloc(sizeof(uint32_t) * dl_info[i]->n_harq_status); for (j = 0; j < dl_info[i]->n_harq_status; j++) { + dl_info[i]->harq_status[j] = harq_pid_round[UE_id][available_harq[UE_id]]; // TODO: This should be different per TB - if(harq_status == 0) - dl_info[i]->harq_status[j] = PROTOCOL__FLEX_HARQ_STATUS__FLHS_ACK; - else if (harq_status > 0) - dl_info[i]->harq_status[j] = PROTOCOL__FLEX_HARQ_STATUS__FLHS_NACK; + } + // LOG_I(FLEXRAN_AGENT, "Sending subframe trigger for frame %d and subframe %d and harq %d (round %d)\n", flexran_get_current_frame(mod_id), (flexran_get_current_subframe(mod_id) + 1) % 10, dl_info[i]->harq_process_id, dl_info[i]->harq_status[0]); + if(dl_info[i]->harq_status[0] > 0) { + // LOG_I(FLEXRAN_AGENT, "[Frame %d][Subframe %d]Need to make a retransmission for harq %d (round %d)\n", flexran_get_current_frame(mod_id), flexran_get_current_subframe(mod_id), dl_info[i]->harq_process_id, dl_info[i]->harq_status[0]); } /*Fill in the serving cell index for this UE */ dl_info[i]->serv_cell_index = UE_PCCID(mod_id,i); @@ -1234,12 +1268,18 @@ int flexran_agent_mac_handle_dl_mac_config(mid_t mod_id, const void *params, Pro } void flexran_agent_init_mac_agent(mid_t mod_id) { + int i, j; lfds700_misc_library_init_valid_on_current_logical_core(); lfds700_misc_prng_init(&ps[mod_id]); int num_elements = RINGBUFFER_SIZE + 1; //Allow RINGBUFFER_SIZE messages to be stored in the ringbuffer at any time dl_mac_config_array[mod_id] = malloc( sizeof(struct lfds700_ringbuffer_element) * num_elements); lfds700_ringbuffer_init_valid_on_current_logical_core( &ringbuffer_state[mod_id], dl_mac_config_array[mod_id], num_elements, &ps[mod_id], NULL ); + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (j = 0; j < 8; j++) { + harq_pid_updated[i][j] = 0; + } + } } /*********************************************** diff --git a/openair2/ENB_APP/MESSAGES/V2/stats_common.proto b/openair2/ENB_APP/MESSAGES/V2/stats_common.proto index 70f99618ac3f4d959fe698c2644da9aecb17ddae..080883ea97997ace22b23e96f5643b59a25e8776 100644 --- a/openair2/ENB_APP/MESSAGES/V2/stats_common.proto +++ b/openair2/ENB_APP/MESSAGES/V2/stats_common.proto @@ -166,6 +166,7 @@ message flex_ul_cqi_report { message flex_pucch_dbm { optional int32 p0_pucch_dbm = 1; optional uint32 serv_cell_index = 2; + optional uint32 p0_pucch_updated = 3; } // diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 1841d8e9a90631517f995bf73f78ea57134666a6..2a48aefbaf81376f6d0058513bdf7e950efa123a 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -2391,10 +2391,11 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) enb_properties.properties[enb_properties_index]->rrh_gw_config[j].usrp_x300 = 1; } else if (strcmp(rf_preference, "bladerf") == 0) { enb_properties.properties[enb_properties_index]->rrh_gw_config[j].bladerf = 1; - } else if (strcmp(rf_preference, "bladerf") == 0) { + } else if (strcmp(rf_preference, "lmsdr") == 0) { enb_properties.properties[enb_properties_index]->rrh_gw_config[j].lmssdr = 1; } else {//if (strcmp(preference, "no") == 0) - enb_properties.properties[enb_properties_index]->rrh_gw_config[j].exmimo = 1; + + enb_properties.properties[enb_properties_index]->rrh_gw_config[j].exmimo = 1; enb_properties.properties[enb_properties_index]->rrh_gw_config[j].usrp_b200 = 1; enb_properties.properties[enb_properties_index]->rrh_gw_config[j].usrp_x300 = 1; enb_properties.properties[enb_properties_index]->rrh_gw_config[j].bladerf = 1; diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index 22793f16b490d46ec9eec1da737c6e78ad3121b2..f2d00145a05c9f752db5544fc14f35acb0ef9d86 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -516,15 +516,14 @@ uint16_t flexran_get_future_sfn_sf (mid_t mod_id, int ahead_of_time) { subframe = (sub_frame_t) flexran_get_current_subframe(mod_id); subframe = ((subframe + ahead_of_time) % 10); - - int full_frames_ahead = ((ahead_of_time / 10) % 10); - frame = frame + full_frames_ahead; - if (subframe < flexran_get_current_subframe(mod_id)) { - frame++; + frame = (frame + 1) % 1024; } - + + int additional_frames = ahead_of_time / 10; + frame = (frame + additional_frames) % 1024; + frame_mask = ((1<<12) - 1); sf_mask = ((1<<4) - 1); sfn_sf = (subframe & sf_mask) | ((frame & frame_mask) << 4); @@ -553,69 +552,81 @@ int flexran_get_ue_phr (mid_t mod_id, mid_t ue_id) { } int flexran_get_ue_wcqi (mid_t mod_id, mid_t ue_id) { - return ((UE_list_t *)enb_ue[mod_id])->eNB_UE_stats[UE_PCCID(mod_id,ue_id)][ue_id].dl_cqi; + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, 0, UE_RNTI(mod_id, ue_id)); + return eNB_UE_stats->DL_cqi[0]; + + // return ((UE_list_t *)enb_ue[mod_id])->eNB_UE_stats[UE_PCCID(mod_id,ue_id)][ue_id].dl_cqi; } int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { - rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - uint16_t frame = (uint16_t) flexran_get_current_frame(mod_id); - mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id,frame,ENB_FLAG_YES,MBMS_FLAG_NO,channel_id,0); - return rlc_status.bytes_in_buffer; + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + uint16_t frame = (uint16_t) flexran_get_current_frame(mod_id); + mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id,frame,ENB_FLAG_YES,MBMS_FLAG_NO, channel_id, 0); + return rlc_status.bytes_in_buffer; } -int flexran_update_TA(mid_t mod_id, mid_t ue_id, int CC_id) { +int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id) { + rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + uint16_t frame = (uint16_t) flexran_get_current_frame(mod_id); + mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id, rnti, mod_id, frame, ENB_FLAG_YES, MBMS_FLAG_NO, channel_id, 0); + return rlc_status.head_sdu_creation_time; +} + +short flexran_get_TA(mid_t mod_id, mid_t ue_id, int CC_id) { UE_list_t *UE_list=&eNB_mac_inst[mod_id].UE_list; - UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[ue_id]; int rnti; rnti = flexran_get_ue_crnti(mod_id, ue_id); - if (ue_sched_ctl->ta_timer == 0) { - // WE SHOULD PROTECT the eNB_UE_stats with a mutex here ... - LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - ue_sched_ctl->ta_timer = 20; // wait 20 subframes before taking TA measurement from PHY - switch (PHY_vars_eNB_g[mod_id][CC_id]->frame_parms.N_RB_DL) { - case 6: - ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update; - break; - - case 15: - ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/2; - break; - - case 25: - ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/4; - break; - - case 50: - ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/8; - break; - - case 75: - ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/12; - break; - - case 100: - ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/16; - break; + LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); + //ue_sched_ctl->ta_timer = 20; // wait 20 subframes before taking TA measurement from PHY + switch (PHY_vars_eNB_g[mod_id][CC_id]->frame_parms.N_RB_DL) { + case 6: + return eNB_UE_stats->timing_advance_update; + case 15: + return eNB_UE_stats->timing_advance_update/2; + case 25: + return eNB_UE_stats->timing_advance_update/4; + case 50: + return eNB_UE_stats->timing_advance_update/8; + case 75: + return eNB_UE_stats->timing_advance_update/12; + case 100: + if (PHY_vars_eNB_g[mod_id][CC_id]->frame_parms.threequarter_fs == 0) { + return eNB_UE_stats->timing_advance_update/16; + } else { + return eNB_UE_stats->timing_advance_update/12; } - // clear the update in case PHY does not have a new measurement after timer expiry - eNB_UE_stats->timing_advance_update = 0; - } - else { - ue_sched_ctl->ta_timer--; - ue_sched_ctl->ta_update = 0; // don't trigger a timing advance command + default: + return 0; } +} - return ue_sched_ctl->ta_update = 0; +void flexran_update_TA(mid_t mod_id, mid_t ue_id, int CC_id) { + + UE_list_t *UE_list=&eNB_mac_inst[mod_id].UE_list; + UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[ue_id]; + + if (ue_sched_ctl->ta_timer == 0) { + + // WE SHOULD PROTECT the eNB_UE_stats with a mutex here ... + // LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); + //ue_sched_ctl->ta_timer = 20; // wait 20 subframes before taking TA measurement from PHY + ue_sched_ctl->ta_update = flexran_get_TA(mod_id, ue_id, CC_id); + // clear the update in case PHY does not have a new measurement after timer expiry + // eNB_UE_stats->timing_advance_update = 0; + } else { + ue_sched_ctl->ta_timer--; + ue_sched_ctl->ta_update = 0; // don't trigger a timing advance command + } } int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id,int CC_id) { UE_list_t *UE_list = &eNB_mac_inst[mod_id].UE_list; - UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[ue_id]; rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); @@ -624,8 +635,8 @@ int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id,int CC_id) { return 0; } - if (ue_sched_ctl->ta_update == 0) { - return 1; + if (flexran_get_TA(mod_id, ue_id, CC_id) != 0) { + return PROTOCOL__FLEX_CE_TYPE__FLPCET_TA; } else { return 0; } @@ -680,8 +691,13 @@ int flexran_get_tpc(mid_t mod_id, mid_t ue_id) { return tpc; } -int flexran_get_harq(const mid_t mod_id, const uint8_t CC_id, const mid_t ue_id, const int frame, const uint8_t subframe, - unsigned char *id, unsigned char *round) { //flag_id_status = 0 then id, else status +int flexran_get_harq(const mid_t mod_id, + const uint8_t CC_id, + const mid_t ue_id, + const int frame, + const uint8_t subframe, + uint8_t *id, + uint8_t *round) { //flag_id_status = 0 then id, else status /*TODO: Add int TB in function parameters to get the status of the second TB. This can be done to by editing in * get_ue_active_harq_pid function in line 272 file: phy_procedures_lte_eNB.c to add * DLSCH_ptr = PHY_vars_eNB_g[Mod_id][CC_id]->dlsch_eNB[(uint32_t)UE_id][1];*/ @@ -707,43 +723,43 @@ int flexran_get_harq(const mid_t mod_id, const uint8_t CC_id, const mid_t ue_id, } int flexran_get_p0_pucch_dbm(mid_t mod_id, mid_t ue_id, int CC_id) { - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - - if (eNB_UE_stats == NULL) { - return -1; - } - - if(eNB_UE_stats->Po_PUCCH_update == 1) { - return eNB_UE_stats->Po_PUCCH_dBm; - } - else - return -1; + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + + eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); + + if (eNB_UE_stats == NULL) { + return -1; + } + + // if(eNB_UE_stats->Po_PUCCH_update == 1) { + return eNB_UE_stats->Po_PUCCH_dBm; + //} + //else + // return -1; } int flexran_get_p0_nominal_pucch(mid_t mod_id, int CC_id) { - int32_t pucch_rx_received = mac_xface->get_target_pucch_rx_power(mod_id, CC_id); - return pucch_rx_received; + int32_t pucch_rx_received = mac_xface->get_target_pucch_rx_power(mod_id, CC_id); + return pucch_rx_received; } int flexran_get_p0_pucch_status(mid_t mod_id, mid_t ue_id, int CC_id) { - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - return eNB_UE_stats->Po_PUCCH_update; + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + + eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); + return eNB_UE_stats->Po_PUCCH_update; } int flexran_update_p0_pucch(mid_t mod_id, mid_t ue_id, int CC_id) { - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); - eNB_UE_stats->Po_PUCCH_update = 0; - - return 0; + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + uint32_t rnti = flexran_get_ue_crnti(mod_id,ue_id); + + eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id, CC_id, rnti); + eNB_UE_stats->Po_PUCCH_update = 0; + + return 0; } diff --git a/openair2/ENB_APP/flexran_agent_common.h b/openair2/ENB_APP/flexran_agent_common.h index a4ee53067cd2731d30337c42a58e50a7c39dbee3..abe5a05b447fe206e7f0bc857c82019806037277 100644 --- a/openair2/ENB_APP/flexran_agent_common.h +++ b/openair2/ENB_APP/flexran_agent_common.h @@ -185,8 +185,14 @@ int flexran_get_ue_wcqi (mid_t mod_id, mid_t ue_id); /* Get the transmission queue size for a UE with a channel_id logical channel id */ int flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); +/* Get the head of line delay for a UE with a channel_id logical channel id */ +int flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t channel_id); + +/* Check the status of the timing advance for a UE */ +short flexran_get_TA(mid_t mod_id, mid_t ue_id, int CC_id); + /* Update the timing advance status (find out whether a timing advance command is required) */ -int flexran_update_TA(mid_t mod_id, mid_t ue_id, int CC_id); +void flexran_update_TA(mid_t mod_id, mid_t ue_id, int CC_id); /* Return timing advance MAC control element for a designated cell and UE */ int flexran_get_MAC_CE_bitmap_TA(mid_t mod_id, mid_t ue_id, int CC_id); diff --git a/openair2/ENB_APP/flexran_agent_extern.h b/openair2/ENB_APP/flexran_agent_extern.h index 3a03239e6fe5c0845c74e2ac724fe875eaa78404..4a04d5d3a670b290ab8009e6a61adb79a168b27a 100644 --- a/openair2/ENB_APP/flexran_agent_extern.h +++ b/openair2/ENB_APP/flexran_agent_extern.h @@ -45,4 +45,8 @@ extern AGENT_MAC_xface *agent_mac_xface[NUM_MAX_ENB]; /* Flag indicating whether the VSFs for the MAC control module have been registered */ extern unsigned int mac_agent_registered[NUM_MAX_ENB]; +/* Requried to know which UEs had a harq updated over some subframe */ +extern int harq_pid_updated[NUMBER_OF_UE_MAX][8]; +extern int harq_pid_round[NUMBER_OF_UE_MAX][8]; + #endif diff --git a/openair2/ENB_APP/flexran_agent_handler.c b/openair2/ENB_APP/flexran_agent_handler.c index 4326ab6be03241df516c82d6f2f27129f2a2599a..29a1c1000c369c33fc2de403e277310133fdc976 100644 --- a/openair2/ENB_APP/flexran_agent_handler.c +++ b/openair2/ENB_APP/flexran_agent_handler.c @@ -172,7 +172,7 @@ Protocol__FlexranMessage* flexran_agent_process_timeout(long timer_id, void* tim struct flexran_agent_timer_element_s *found = get_timer_entry(timer_id); if (found == NULL ) goto error; - LOG_I(FLEXRAN_AGENT, "Found the entry (%p): timer_id is 0x%lx 0x%lx\n", found, timer_id, found->timer_id); + LOG_D(FLEXRAN_AGENT, "Found the entry (%p): timer_id is 0x%lx 0x%lx\n", found, timer_id, found->timer_id); if (timer_args == NULL) LOG_W(FLEXRAN_AGENT,"null timer args\n"); diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 63501128ef41359cdddb3f9dadaf87eeb67c3fdf..3c0223e59e831476c2fe66db0d22371ecae95b85 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -132,6 +132,10 @@ #define MIN_CQI_VALUE 0 /*!\brief maximum value for channel quality indicator */ #define MAX_CQI_VALUE 15 +/*!\briefmaximum number of supported bandwidth (1.4, 5, 10, 20 MHz) */ +#define MAX_SUPPORTED_BW 4 +/*!\brief CQI values range from 1 to 15 (4 bits) */ +#define CQI_VALUE_RANGE 16 /*!\brief value for indicating BSR Timer is not running */ #define MAC_UE_BSR_TIMER_NOT_RUNNING (0xFFFF) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 1a61c669480e7fe35b6af6d80e885d27cc9dc1da..dee7c51a6e514178f1521d8c7484fa7ddad7e395 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -104,6 +104,8 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, rnti_t rnti; void *DLSCH_dci=NULL; int size_bits=0,size_bytes=0; + + LTE_eNB_UE_stats *eNB_UE_stats = NULL; #if defined(FLEXRAN_AGENT_SB_IF) Protocol__FlexranMessage *msg; @@ -150,9 +152,9 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, eNB_mac_inst[module_idP].UE_list.UE_sched_ctrl[i].ul_inactivity_timer++; eNB_mac_inst[module_idP].UE_list.UE_sched_ctrl[i].cqi_req_timer++; - + eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); - if (mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti)==NULL) { + if (eNB_UE_stats==NULL) { //mac_remove_ue(module_idP, i, frameP, subframeP); //Inform the controller about the UE deactivation. Should be moved to RRC agent in the future #if defined(FLEXRAN_AGENT_SB_IF) @@ -247,8 +249,8 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, add_ue_spec_dci(DCI_pdu[CC_id], DLSCH_dci, rnti, - size_bytes, - process_ue_cqi (module_idP,i),//aggregation, + size_bytes, + get_aggregation(get_bw_index(module_idP,CC_id),eNB_UE_stats->DL_cqi[0],format1A), size_bits, format1A, 0); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 3933fe3f8dea5eae172fdc5db8a329732023df98..41a136d6b1eb2f86e95194a2832b88adaf69c086 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -463,7 +463,7 @@ schedule_ue_spec( VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_IN); //weight = get_ue_weight(module_idP,UE_id); - aggregation = 1; // set to the maximum aggregation level + aggregation = 2; for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { min_rb_unit[CC_id]=get_min_rb_unit(module_idP,CC_id); @@ -520,7 +520,25 @@ schedule_ue_spec( // mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); continue_flag=1; } - + + switch(mac_xface->get_transmission_mode(module_idP,CC_id,rnti)){ + case 1: + case 2: + case 7: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + eNB_UE_stats->DL_cqi[0], + format1); + break; + case 3: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + eNB_UE_stats->DL_cqi[0], + format2A); + break; + default: + LOG_W(MAC,"Unsupported transmission mode %d\n", mac_xface->get_transmission_mode(module_idP,CC_id,rnti)); + aggregation = 2; + } + if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated CCE_allocation_infeasible(module_idP,CC_id,0,subframeP,aggregation,rnti) ) { @@ -630,9 +648,6 @@ schedule_ue_spec( } nb_available_rb -= nb_rb; - aggregation = process_ue_cqi(module_idP,UE_id); - - PHY_vars_eNB_g[module_idP][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; PHY_vars_eNB_g[module_idP][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; @@ -1120,8 +1135,7 @@ schedule_ue_spec( T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS)); - aggregation = process_ue_cqi(module_idP,UE_id); - UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; + UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; add_ue_dlsch_info(module_idP, CC_id, @@ -1519,7 +1533,8 @@ fill_DLSCH_dci( eNB_MAC_INST *eNB =&eNB_mac_inst[module_idP]; UE_list_t *UE_list = &eNB->UE_list; //RA_TEMPLATE *RA_template; - + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + start_meas(&eNB->fill_DLSCH_dci); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI,VCD_FUNCTION_IN); @@ -1546,6 +1561,7 @@ fill_DLSCH_dci( nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; DLSCH_dci = (void *)UE_list->UE_template[CC_id][UE_id].DLSCH_DCI[harq_pid]; + eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); /// Synchronizing rballoc with rballoc_sub @@ -1645,7 +1661,7 @@ fill_DLSCH_dci( DLSCH_dci, rnti, size_bytes, - process_ue_cqi (module_idP,UE_id),//aggregation, + get_aggregation(get_bw_index(module_idP,CC_id),eNB_UE_stats->DL_cqi[0],format1), size_bits, format1, 0); @@ -1741,8 +1757,8 @@ fill_DLSCH_dci( DLSCH_dci, rnti, size_bytes, - process_ue_cqi (module_idP,UE_id),//aggregation, - size_bits, + get_aggregation(get_bw_index(module_idP,CC_id),eNB_UE_stats->DL_cqi[0],format2A), + size_bits, format2A, 0); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 9dfd2f095b230ae3d7595120622b12ab13235c4b..da9e8572baf6c01b5e666754f81c448ce41db7cd 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -181,11 +181,41 @@ uint8_t find_active_UEs(module_id_t module_idP,int CC_id){ */ -// get aggregatiob form phy for a give UE -unsigned char process_ue_cqi (module_id_t module_idP, int ue_idP) +// get aggregation (L) form phy for a give UE +unsigned char get_aggregation (uint8_t bw_index, uint8_t cqi, uint8_t dci_fmt) { - unsigned char aggregation=1; - // check the MCS and SNR and set the aggregation accordingly + unsigned char aggregation=3; + + switch (dci_fmt){ + + case format0: + aggregation = cqi2fmt0_agg[bw_index][cqi]; + break; + case format1: + case format1A: + case format1B: + case format1D: + aggregation = cqi2fmt1x_agg[bw_index][cqi]; + break; + case format2: + case format2A: + case format2B: + case format2C: + case format2D: + aggregation = cqi2fmt2x_agg[bw_index][cqi]; + break; + case format1C: + case format1E_2A_M10PRB: + case format3: + case format3A: + case format4: + default: + LOG_W(MAC,"unsupported DCI format %d\n",dci_fmt); + } + + LOG_D(MAC,"Aggregation level %d (cqi %d, bw_index %d, format %d)\n", + 1<<aggregation, cqi,bw_index,dci_fmt); + return aggregation; } #ifdef CBA @@ -714,6 +744,38 @@ uint32_t allocate_prbs(int UE_id,unsigned char nb_rb, uint32_t *rballoc) return(rballoc_dci); } +int get_bw_index(module_id_t module_id, uint8_t CC_id) +{ + + int bw_index=0; + LTE_DL_FRAME_PARMS* frame_parms = mac_xface->get_lte_frame_parms(module_id,CC_id); + + switch (frame_parms->N_RB_DL) { + case 6: // 1.4 MHz + bw_index=0; + break; + + case 25: // 5HMz + bw_index=1; + break; + + case 50: // 10HMz + bw_index=2; + break; + + case 100: // 20HMz + bw_index=3; + break; + + default: + bw_index=1; + LOG_W(MAC,"[eNB %d] N_DL_RB %d unknown for CC_id %d, setting bw_index to 1\n", module_id, CC_id); + break; + } + + return bw_index; +} + int get_min_rb_unit(module_id_t module_id, uint8_t CC_id) { @@ -1044,8 +1106,7 @@ try_again: 1<<DCI_pdu->dci_alloc[j].L, nCCE,nCCE_max,DCI_pdu->num_pdcch_symbols); } - //dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,dci_alloc->L); - + //dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,1<<dci_alloc->L); goto failed; } DCI_pdu->num_pdcch_symbols++; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 3fd1ba6508826ca661ea81ff467c32a52df9bb54..6d0044b346a2484aeccedb1a4932572eb8e1b7cd 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -729,8 +729,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, ulsch_scheduler_pre_processor(module_idP, frameP, subframeP, - first_rb, - aggregation); + first_rb); // LOG_I(MAC,"exiting ulsch preprocesor\n"); @@ -791,14 +790,19 @@ abort(); frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); + aggregation=get_aggregation(get_bw_index(module_idP,CC_id), + eNB_UE_stats->DL_cqi[0], + format0); + if (CCE_allocation_infeasible(module_idP,CC_id,0,subframeP,aggregation,rnti)) { LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: not enough nCCE\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id); continue; // break; + } else{ + LOG_D(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d mode %s: aggregation level %d\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id, mode_string[eNB_UE_stats->mode], 1<<aggregation); } - // printf("UE %d/%x is feasible, mode %s\n",UE_id,rnti,mode_string[eNB_UE_stats->mode]); - if (eNB_UE_stats->mode == PUSCH) { // ue has a ulsch channel DCI_pdu = &eNB->common_channels[CC_id].DCI_pdu; @@ -824,7 +828,6 @@ abort(); UE_sched_ctrl->ul_failure_timer); // reset the scheduling request UE_template->ul_SR = 0; - aggregation = process_ue_cqi(module_idP,UE_id); status = mac_eNB_get_rrc_status(module_idP,rnti); if (status < RRC_CONNECTED) cqi_req = 0; diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/extern.h index aed8424561c82690379945bab9309c786f475b3f..1da6fe5a69633ccb075d0b298cb129f88f51a310 100644 --- a/openair2/LAYER2/MAC/extern.h +++ b/openair2/LAYER2/MAC/extern.h @@ -50,6 +50,12 @@ extern const uint32_t BSR_TABLE[BSR_TABLE_SIZE]; extern const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE]; //extern uint32_t Extended_BSR_TABLE[63]; ----currently not used +extern const uint8_t cqi2fmt0_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE]; + +extern const uint8_t cqi2fmt1x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE]; + +extern const uint8_t cqi2fmt2x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE]; + extern UE_MAC_INST *UE_mac_inst; extern eNB_MAC_INST *eNB_mac_inst; extern eNB_RRC_INST *eNB_rrc_inst; diff --git a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h index 6757500dc2cc7175e48ea11c0ccb93d310904bf7..a3ff3b6a4aa9ee88b176b795d3246312e0ddfcc0 100644 --- a/openair2/LAYER2/MAC/flexran_agent_mac_proto.h +++ b/openair2/LAYER2/MAC/flexran_agent_mac_proto.h @@ -131,19 +131,6 @@ void _assign_rbs_required (module_id_t Mod_id, uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES], int min_rb_unit[MAX_NUM_CCs]); -int _maxround(module_id_t Mod_id, - uint16_t rnti, - int frame, - sub_frame_t subframe, - uint8_t ul_flag ); - -int _maxcqi(module_id_t Mod_id, - int32_t UE_id); - -void _sort_UEs (module_id_t Mod_idP, - int frameP, - sub_frame_t subframeP); - void _dlsch_scheduler_pre_processor (module_id_t Mod_id, int slice_id, frame_t frameP, diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c index c9956bd9ce937c055c4b75913e3e72226a87ace6..9c8b23df07a3545188c260f9fbbe7165dfb0ae93 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dataplane.c @@ -53,6 +53,9 @@ #include "header.pb-c.h" #include "flexran.pb-c.h" +#include "flexran_agent_extern.h" + +#include "flexran_agent_common.h" #include "SIMULATION/TOOLS/defs.h" // for taus @@ -97,10 +100,10 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, unsigned char header_len = 0, header_len_tmp = 0; unsigned char sdu_lcids[11],offset,num_sdus=0; uint16_t nb_rb; - uint16_t TBS,j,sdu_lengths[11],rnti,padding=0,post_padding=0; + uint16_t TBS, sdu_lengths[11],rnti,padding=0,post_padding=0; unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; - unsigned char round = 0; - unsigned char harq_pid = 0; + uint8_t round = 0; + uint8_t harq_pid = 0; // LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; LTE_eNB_UE_stats *eNB_UE_stats = NULL; uint16_t sdu_length_total = 0; @@ -112,17 +115,16 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, int last_sdu_header_len = 0; - int i; + int i, j; Protocol__FlexDlData *dl_data; Protocol__FlexDlDci *dl_dci; uint32_t rlc_size, n_lc, lcid; - // For each UE-related command for (i = 0; i < n_dl_ue_data; i++) { - + dl_data = dl_ue_data[i]; dl_dci = dl_data->dl_dci; @@ -138,6 +140,9 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, round = dl_dci->rv[0]; harq_pid = dl_dci->harq_process; + //LOG_I(FLEXRAN_AGENT, "[Frame %d][Subframe %d] Scheduling harq %d\n", frame, subframe, harq_pid); + // LOG_I(FLEXRAN_AGENT, "[Frame %d][Subframe %d]Now scheduling harq_pid %d (round %d)\n", frame, subframe, harq_pid, round); + // If this is a new transmission if (round == 0) { // First we have to deal with the creation of the PDU based on the message instructions @@ -147,27 +152,22 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, if (dl_data->n_ce_bitmap > 0) { //Check if there is TA command and set the length appropriately - ta_len = (dl_data->ce_bitmap[0] & PROTOCOL__FLEX_CE_TYPE__FLPCET_TA) ? 1 : 0; + ta_len = (dl_data->ce_bitmap[0] & PROTOCOL__FLEX_CE_TYPE__FLPCET_TA) ? 2 : 0; } - + num_sdus = 0; sdu_length_total = 0; - if (ta_len > 0) { - // Reset the measurement - ue_sched_ctl->ta_timer = 20; - eNB_UE_stats->timing_advance_update = 0; - header_len = ta_len; - last_sdu_header_len = ta_len; - } - n_lc = dl_data->n_rlc_pdu; // Go through each one of the channel commands and create SDUs - for (i = 0; i < n_lc; i++) { - lcid = dl_data->rlc_pdu[i]->rlc_pdu_tb[0]->logical_channel_id; - rlc_size = dl_data->rlc_pdu[i]->rlc_pdu_tb[0]->size; - LOG_D(MAC,"[TEST] [eNB %d] Frame %d, LCID %d, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - mod_id, frame, lcid, CC_id, rlc_size); + header_len = 0; + last_sdu_header_len = 0; + for (j = 0; j < n_lc; j++) { + sdu_lengths[j] = 0; + lcid = dl_data->rlc_pdu[j]->rlc_pdu_tb[0]->logical_channel_id; + rlc_size = dl_data->rlc_pdu[j]->rlc_pdu_tb[0]->size; + LOG_D(MAC,"[TEST] [eNB %d] [Frame %d] [Subframe %d], LCID %d, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + mod_id, frame, subframe, lcid, CC_id, rlc_size); if (rlc_size > 0) { rlc_status = mac_rlc_status_ind(mod_id, @@ -181,10 +181,14 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, if (rlc_status.bytes_in_buffer > 0) { - if (rlc_size <= 2) { - rlc_size = 3; + if (rlc_status.bytes_in_buffer < rlc_size) { + rlc_size = rlc_status.bytes_in_buffer; } + if (rlc_size <= 2) { + rlc_size = 3; + } + rlc_status = mac_rlc_status_ind(mod_id, rnti, mod_id, @@ -194,29 +198,27 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, lcid, rlc_size); // transport block set size - sdu_lengths[i] = 0; - LOG_D(MAC, "[TEST] RLC can give %d bytes for LCID %d during second call\n", rlc_status.bytes_in_buffer, lcid); if (rlc_status.bytes_in_buffer > 0) { - sdu_lengths[i] += mac_rlc_data_req(mod_id, - rnti, - mod_id, - frame, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - (char *)&dlsch_buffer[sdu_length_total]); + sdu_lengths[j] = mac_rlc_data_req(mod_id, + rnti, + mod_id, + frame, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + (char *)&dlsch_buffer[sdu_length_total]); - LOG_D(MAC,"[eNB %d][LCID %d] CC_id %d Got %d bytes from RLC\n",mod_id, lcid, CC_id, sdu_lengths[i]); - sdu_length_total += sdu_lengths[i]; - sdu_lcids[i] = lcid; + LOG_D(MAC,"[eNB %d][LCID %d] CC_id %d Got %d bytes from RLC\n",mod_id, lcid, CC_id, sdu_lengths[j]); + sdu_length_total += sdu_lengths[j]; + sdu_lcids[j] = lcid; UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid] += 1; - UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[i]; + UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[j]; - if (sdu_lengths[i] <= 128) { + if (sdu_lengths[j] < 128) { header_len += 2; last_sdu_header_len = 2; } else { @@ -230,38 +232,46 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, } // SDU creation end - if (((sdu_length_total + header_len) > 0)) { - - // header_len_tmp = header_len; + if (((sdu_length_total + header_len + ta_len) > 0)) { + + header_len_tmp = header_len; // If we have only a single SDU, header length becomes 1 - if ((num_sdus + ta_len) == 1) { + if ((num_sdus) == 1) { //if (header_len == 2 || header_len == 3) { header_len = 1; } else { header_len = (header_len - last_sdu_header_len) + 1; } - // there is a payload - if (((sdu_length_total + header_len) > 0)) { - // If we need a 1 or 2 bit padding or no padding at all - if ((TBS - header_len - sdu_length_total - ta_len) <= 2 - || (TBS - header_len - sdu_length_total - ta_len) > TBS) { //protect from overflow - padding = (TBS - header_len - sdu_length_total - ta_len); - post_padding = 0; - } else { // The last sdu needs to have a length field, since we add padding - padding = 0; - header_len = header_len_tmp; - post_padding = TBS - sdu_length_total - header_len - ta_len - 1; // 1 is for the postpadding header - } + // If we need a 1 or 2 bit padding or no padding at all + if ((TBS - header_len - sdu_length_total - ta_len) <= 2 + || (TBS - header_len - sdu_length_total - ta_len) > TBS) { //protect from overflow + padding = (TBS - header_len - sdu_length_total - ta_len); + post_padding = 0; + } else { // The last sdu needs to have a length field, since we add padding + padding = 0; + header_len = header_len_tmp; + post_padding = TBS - sdu_length_total - header_len - ta_len; // 1 is for the postpadding header + } + + if (ta_len > 0) { + // Reset the measurement + ta_update = flexran_get_TA(mod_id, UE_id, CC_id); + ue_sched_ctl->ta_timer = 20; + eNB_UE_stats->timing_advance_update = 0; + } else { + ta_update = 0; } - - ta_update = (ta_len > 0) ? ue_sched_ctl->ta_update : 0; // If there is nothing to schedule, just leave if ((sdu_length_total) <= 0) { - return; + harq_pid_updated[UE_id][harq_pid] = 1; + harq_pid_round[UE_id][harq_pid] = 0; + continue; } + + // LOG_I(FLEXRAN_AGENT, "[Frame %d][Subframe %d] TBS is %d and bytes are %d\n", frame, subframe, TBS, sdu_length_total); offset = generate_dlsch_header((unsigned char*)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], num_sdus, //num_sdus @@ -272,6 +282,10 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, NULL, // contention res id padding, post_padding); + + + + #ifdef DEBUG_eNB_SCHEDULER LOG_T(MAC,"[eNB %d] First 16 bytes of DLSCH : \n"); @@ -289,7 +303,7 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, // fill remainder of DLSCH with random data for (j=0; j<(TBS-sdu_length_total-offset); j++) { UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset+sdu_length_total+j] = (char)(taus()&0xff); - } + } //eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset+sdu_lengths[0]+j] = (char)(taus()&0xff); if (opt_enabled == 1) { @@ -319,6 +333,8 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, nb_rb += get_min_rb_unit(mod_id, CC_id); stats_tbs = mac_xface->get_TBS_DL(dl_dci->mcs[0], nb_rb); } + + // LOG_I(FLEXRAN_AGENT, "The MCS was %d\n", dl_dci->mcs[0]); UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb; UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += nb_rb; @@ -333,10 +349,14 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, //eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[eNB_UE_stats->DL_cqi[0]]; //eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1, openair_daq_vars.target_ue_dl_mcs); + } else { + LOG_D(FLEXRAN_AGENT, "No need to schedule a dci after all. Just drop it\n"); + harq_pid_updated[UE_id][harq_pid] = 1; + harq_pid_round[UE_id][harq_pid] = 0; + continue; } } else { // No need to create anything apart of DCI in case of retransmission - /*TODO: Must add these */ // eNB_UE_stats->dlsch_trials[round]++; //UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission+=1; @@ -345,8 +365,8 @@ void flexran_apply_ue_spec_scheduling_decisions(mid_t mod_id, //UE_list->eNB_UE_stats[CC_id][UE_id].ncce_used_retx=nCCECC_id]; } - UE_list->UE_template[CC_id][UE_id].oldNDI[dl_dci->harq_process] = dl_dci->ndi[0]; - eNB_UE_stats->dlsch_mcs1 = dl_dci->mcs[0]; + // UE_list->UE_template[CC_id][UE_id].oldNDI[dl_dci->harq_process] = dl_dci->ndi[0]; + // eNB_UE_stats->dlsch_mcs1 = dl_dci->mcs[0]; //Fill the proper DCI of OAI flexran_fill_oai_dci(mod_id, CC_id, rnti, dl_dci); diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index 3af246a5d5be3e547ce533b5655ee7266d648c53..00027f04ce1f46ffdceefbe1bfd0e2b56a16b3e7 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -104,8 +104,8 @@ float total_slice_percentage = 0; int slice_maxmcs[MAX_NUM_SLICES] = {28, 28, 28, 28}; int slice_maxmcs_current[MAX_NUM_SLICES] = {28, 28, 28, 28}; -int update_dl_scheduler[MAX_NUM_SLICES] = {1, 0, 0, 0}; -int update_dl_scheduler_current[MAX_NUM_SLICES] = {1, 0, 0, 0}; +int update_dl_scheduler[MAX_NUM_SLICES] = {1, 1, 1, 1}; +int update_dl_scheduler_current[MAX_NUM_SLICES] = {1, 1, 1, 1}; // name of available scheduler char *dl_scheduler_type[MAX_NUM_SLICES] = {"flexran_schedule_ue_spec_embb", @@ -137,8 +137,9 @@ void _store_dlsch_buffer (module_id_t Mod_id, UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; UE_TEMPLATE *UE_template; - for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { - + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (UE_list->active[UE_id] != TRUE) continue; + if (flexran_slice_member(UE_id, slice_id) == 0) continue; @@ -221,7 +222,8 @@ void _assign_rbs_required (module_id_t Mod_id, // UE_TEMPLATE *UE_template; // clear rb allocations across all CC_ids - for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (UE_list->active[UE_id] != TRUE) continue; if (flexran_slice_member(UE_id, slice_id) == 0) continue; @@ -229,11 +231,15 @@ void _assign_rbs_required (module_id_t Mod_id, pCCid = UE_PCCID(Mod_id,UE_id); rnti = UE_list->UE_template[pCCid][UE_id].rnti; + /* skip UE not present in PHY (for any of its active CCs) */ + if (!phy_stats_exist(Mod_id, rnti)) + continue; + //update CQI information across component carriers for (n=0; n<UE_list->numactiveCCs[UE_id]; n++) { CC_id = UE_list->ordered_CCids[n][UE_id]; eNB_UE_stats[CC_id] = mac_xface->get_eNB_UE_stats(Mod_id,CC_id,rnti); - eNB_UE_stats[CC_id]->dlsch_mcs1=cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)]; + eNB_UE_stats[CC_id]->dlsch_mcs1 = cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)]; } // provide the list of CCs sorted according to MCS @@ -260,143 +266,34 @@ void _assign_rbs_required (module_id_t Mod_id, CC_id = UE_list->ordered_CCids[i][UE_id]; eNB_UE_stats[CC_id] = mac_xface->get_eNB_UE_stats(Mod_id,CC_id,rnti); - if (eNB_UE_stats[CC_id]->dlsch_mcs1==0) { + if (cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)] == 0) {//eNB_UE_stats[CC_id]->dlsch_mcs1==0) { nb_rbs_required[CC_id][UE_id] = 4; // don't let the TBS get too small } else { nb_rbs_required[CC_id][UE_id] = min_rb_unit[CC_id]; } - TBS = mac_xface->get_TBS_DL(eNB_UE_stats[CC_id]->dlsch_mcs1,nb_rbs_required[CC_id][UE_id]); + TBS = mac_xface->get_TBS_DL(cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)], nb_rbs_required[CC_id][UE_id]); nb_rbs_allowed_slice[CC_id][slice_id] = flexran_nb_rbs_allowed_slice(slice_percentage[slice_id], flexran_get_N_RB_DL(Mod_id, CC_id)); LOG_D(MAC,"[preprocessor] start RB assignement for UE %d CC_id %d dl buffer %d (RB unit %d, MCS %d, TBS %d) \n", UE_id, CC_id, UE_list->UE_template[pCCid][UE_id].dl_buffer_total, - nb_rbs_required[CC_id][UE_id],eNB_UE_stats[CC_id]->dlsch_mcs1,TBS); + nb_rbs_required[CC_id][UE_id], flexran_get_ue_wcqi(Mod_id, UE_id), TBS); /* calculating required number of RBs for each UE */ while (TBS < UE_list->UE_template[pCCid][UE_id].dl_buffer_total) { nb_rbs_required[CC_id][UE_id] += min_rb_unit[CC_id]; if (nb_rbs_required[CC_id][UE_id] > nb_rbs_allowed_slice[CC_id][slice_id]) { - TBS = mac_xface->get_TBS_DL(eNB_UE_stats[CC_id]->dlsch_mcs1, nb_rbs_allowed_slice[CC_id][slice_id]); + TBS = mac_xface->get_TBS_DL(flexran_get_ue_wcqi(Mod_id, UE_id), nb_rbs_allowed_slice[CC_id][slice_id]); nb_rbs_required[CC_id][UE_id] = nb_rbs_allowed_slice[CC_id][slice_id]; break; } - TBS = mac_xface->get_TBS_DL(eNB_UE_stats[CC_id]->dlsch_mcs1,nb_rbs_required[CC_id][UE_id]); + TBS = mac_xface->get_TBS_DL(cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)], nb_rbs_required[CC_id][UE_id]); } // end of while LOG_D(MAC,"[eNB %d][SLICE %d] Frame %d: UE %d on CC %d: RB unit %d, nb_required RB %d (TBS %d, mcs %d)\n", - Mod_id, slice_id,frameP,UE_id, CC_id, min_rb_unit[CC_id], nb_rbs_required[CC_id][UE_id], TBS, eNB_UE_stats[CC_id]->dlsch_mcs1); - } - } - } -} - -// This function scans all CC_ids for a particular UE to find the maximum round index of its HARQ processes -int _maxround(module_id_t Mod_id,uint16_t rnti,int frame,sub_frame_t subframe,uint8_t ul_flag ) -{ - - uint8_t round,round_max=0,UE_id; - int CC_id; - UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - - UE_id = find_UE_id(Mod_id,rnti); - round = UE_list->UE_sched_ctrl[UE_id].round[CC_id]; - if (round > round_max) { - round_max = round; - } - } - - return round_max; -} - -// This function scans all CC_ids for a particular UE to find the maximum DL CQI -int _maxcqi(module_id_t Mod_id,int32_t UE_id) -{ - - LTE_eNB_UE_stats *eNB_UE_stats = NULL; - UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; - int CC_id,n; - int CQI = 0; - - for (n=0; n<UE_list->numactiveCCs[UE_id]; n++) { - CC_id = UE_list->ordered_CCids[n][UE_id]; - eNB_UE_stats = mac_xface->get_eNB_UE_stats(Mod_id,CC_id,UE_RNTI(Mod_id,UE_id)); - - if (eNB_UE_stats==NULL) { - mac_xface->macphy_exit("maxcqi: could not get eNB_UE_stats\n"); - return 0; // not reached - } - - if (eNB_UE_stats->DL_cqi[0] > CQI) { - CQI = eNB_UE_stats->DL_cqi[0]; - } - } - - return(CQI); -} - - -// This fuction sorts the UE in order their dlsch buffer and CQI -void _sort_UEs (module_id_t Mod_idP, - int frameP, - sub_frame_t subframeP) -{ - - - int UE_id1,UE_id2; - int pCC_id1,pCC_id2; - int cqi1,cqi2,round1,round2; - int i=0,ii=0;//,j=0; - rnti_t rnti1,rnti2; - - UE_list_t *UE_list = &eNB_mac_inst[Mod_idP].UE_list; - - for (i=UE_list->head; i>=0; i=UE_list->next[i]) { - - for(ii=UE_list->next[i]; ii>=0; ii=UE_list->next[ii]) { - - UE_id1 = i; - rnti1 = UE_RNTI(Mod_idP,UE_id1); - if(rnti1 == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[UE_id1].ul_out_of_sync == 1) - continue; - pCC_id1 = UE_PCCID(Mod_idP,UE_id1); - cqi1 = _maxcqi(Mod_idP,UE_id1); // - round1 = _maxround(Mod_idP,rnti1,frameP,subframeP,0); - - UE_id2 = ii; - rnti2 = UE_RNTI(Mod_idP,UE_id2); - if(rnti2 == NOT_A_RNTI) - continue; - if (UE_list->UE_sched_ctrl[UE_id2].ul_out_of_sync == 1) - continue; - cqi2 = _maxcqi(Mod_idP,UE_id2); - round2 = _maxround(Mod_idP,rnti2,frameP,subframeP,0); //mac_xface->get_ue_active_harq_pid(Mod_id,rnti2,subframe,&harq_pid2,&round2,0); - pCC_id2 = UE_PCCID(Mod_idP,UE_id2); - - if(round2 > round1) { // Check first if one of the UEs has an active HARQ process which needs service and swap order - swap_UEs(UE_list,UE_id1,UE_id2,0); - } else if (round2 == round1) { - // RK->NN : I guess this is for fairness in the scheduling. This doesn't make sense unless all UEs have the same configuration of logical channels. This should be done on the sum of all information that has to be sent. And still it wouldn't ensure fairness. It should be based on throughput seen by each UE or maybe using the head_sdu_creation_time, i.e. swap UEs if one is waiting longer for service. - - // first check the buffer status for SRB1 and SRB2 - if ( (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[1] + UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_info[2]) < - (UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[1] + UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_info[2]) ) { - swap_UEs(UE_list,UE_id1,UE_id2,0); - } else if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_head_sdu_creation_time_max < - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_head_sdu_creation_time_max ) { - swap_UEs(UE_list,UE_id1,UE_id2,0); - } else if (UE_list->UE_template[pCC_id1][UE_id1].dl_buffer_total < - UE_list->UE_template[pCC_id2][UE_id2].dl_buffer_total ) { - swap_UEs(UE_list,UE_id1,UE_id2,0); - } else if (cqi1 < cqi2) { - swap_UEs(UE_list,UE_id1,UE_id2,0); - } + Mod_id, slice_id,frameP,UE_id, CC_id, min_rb_unit[CC_id], nb_rbs_required[CC_id][UE_id], TBS, cqi_to_mcs[flexran_get_ue_wcqi(Mod_id, UE_id)]); } } } @@ -543,10 +440,11 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, int *mbsfn_flag) { - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], harq_pid=0, total_ue_count; + unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], total_ue_count; unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]; int UE_id, i; - unsigned char round = 0; + uint8_t round = 0; + uint8_t harq_pid = 0; uint16_t ii,j; uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; uint16_t nb_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; @@ -574,7 +472,9 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, min_rb_unit[CC_id]=get_min_rb_unit(Mod_id,CC_id); - for (i=UE_list->head; i>=0; i=UE_list->next[i]) { + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] != TRUE) continue; + UE_id = i; // Initialize scheduling information for all active UEs @@ -602,24 +502,24 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, _assign_rbs_required (Mod_id,slice_id, frameP,subframeP,nb_rbs_required,nb_rbs_allowed_slice,min_rb_unit); // Sorts the user on the basis of dlsch logical channel buffer and CQI - _sort_UEs (Mod_id,frameP,subframeP); + sort_UEs (Mod_id,frameP,subframeP); total_ue_count = 0; // loop over all active UEs - for (i=UE_list->head; i>=0; i=UE_list->next[i]) { + for (i=UE_list->head; i>=0; i=UE_list->next[i]) { rnti = flexran_get_ue_crnti(Mod_id, i); if(rnti == NOT_A_RNTI) continue; if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) continue; + UE_id = i; if (flexran_slice_member(UE_id, slice_id) == 0) continue; - // if there is no available harq_process, skip the UE - if (UE_list->UE_sched_ctrl[UE_id].harq_pid[CC_id]<0) + if (!phy_stats_exist(Mod_id, rnti)) continue; for (ii=0; ii < UE_num_active_CC(UE_list,UE_id); ii++) { @@ -628,6 +528,10 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, ue_sched_ctl->max_allowed_rbs[CC_id]=nb_rbs_allowed_slice[CC_id][slice_id]; flexran_get_harq(Mod_id, CC_id, UE_id, frameP, subframeP, &harq_pid, &round); + // if there is no available harq_process, skip the UE + if (UE_list->UE_sched_ctrl[UE_id].harq_pid[CC_id]<0) + continue; + average_rbs_per_user[CC_id]=0; frame_parms[CC_id] = mac_xface->get_lte_frame_parms(Mod_id,CC_id); @@ -669,6 +573,15 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, for(i=UE_list->head; i>=0; i=UE_list->next[i]) { rnti = UE_RNTI(Mod_id,i); + if(rnti == NOT_A_RNTI) + continue; + + if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) + continue; + + if (!phy_stats_exist(Mod_id, rnti)) + continue; + if (flexran_slice_member(i, slice_id) == 0) continue; @@ -733,9 +646,13 @@ void _dlsch_scheduler_pre_processor (module_id_t Mod_id, // LOG_D(MAC,"UE %d rnti 0x\n", UE_id, rnti ); if(rnti == NOT_A_RNTI) continue; + if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) continue; + if (!phy_stats_exist(Mod_id, rnti)) + continue; + transmission_mode = mac_xface->get_transmission_mode(Mod_id,CC_id,rnti); //rrc_status = mac_eNB_get_rrc_status(Mod_id,rnti); /* 1st allocate for the retx */ @@ -1027,11 +944,11 @@ flexran_schedule_ue_spec_common(mid_t mod_id, int N_RBG[MAX_NUM_CCs]; unsigned char aggregation; mac_rlc_status_resp_t rlc_status; - unsigned char header_len = 0, ta_len = 0; + unsigned char header_len = 0, header_len_last = 0, ta_len = 0; uint16_t nb_rb, nb_rb_temp, total_nb_available_rb[MAX_NUM_CCs], nb_available_rb; uint16_t TBS, j, rnti; - unsigned char round = 0; - unsigned char harq_pid = 0; + uint8_t round = 0; + uint8_t harq_pid = 0; uint16_t sdu_length_total = 0; int mcs, mcs_tmp; uint16_t min_rb_unit[MAX_NUM_CCs]; @@ -1042,7 +959,7 @@ flexran_schedule_ue_spec_common(mid_t mod_id, int32_t tpc = 1; static int32_t tpc_accumulated=0; UE_sched_ctrl *ue_sched_ctl; - + LTE_eNB_UE_stats *eNB_UE_stats = NULL; Protocol__FlexDlData *dl_data[NUM_MAX_UE]; int num_ues_added = 0; int channels_added = 0; @@ -1058,17 +975,19 @@ flexran_schedule_ue_spec_common(mid_t mod_id, uint8_t ue_has_transmission = 0; uint32_t ndi; - flexran_agent_mac_create_empty_dl_config(mod_id, dl_info); +#if 0 if (UE_list->head==-1) { return; } +#endif + start_meas(&eNB->schedule_dlsch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_IN); //weight = get_ue_weight(module_idP,UE_id); - aggregation = 2; // set to the maximum aggregation level + aggregation = 1; // set to the maximum aggregation level for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { min_rb_unit[CC_id] = get_min_rb_unit(mod_id, CC_id); @@ -1105,11 +1024,19 @@ flexran_schedule_ue_spec_common(mid_t mod_id, if (mbsfn_flag[CC_id]>0) continue; - + for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { + rnti = flexran_get_ue_crnti(mod_id, UE_id); + eNB_UE_stats = mac_xface->get_eNB_UE_stats(mod_id,CC_id,rnti); ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - + + if (eNB_UE_stats==NULL) { + LOG_D(MAC,"[eNB] Cannot find eNB_UE_stats\n"); + // mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); + continue; + } + if (flexran_slice_member(UE_id, slice_id) == 0) continue; @@ -1119,12 +1046,24 @@ flexran_schedule_ue_spec_common(mid_t mod_id, continue; } - if (flexran_get_ue_crnti(mod_id, UE_id) == NOT_A_RNTI) { - LOG_D(MAC,"[eNB] Cannot find UE\n"); - // mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); - continue; + switch(mac_xface->get_transmission_mode(mod_id,CC_id,rnti)){ + case 1: + case 2: + case 7: + aggregation = get_aggregation(get_bw_index(mod_id,CC_id), + eNB_UE_stats->DL_cqi[0], + format1); + break; + case 3: + aggregation = get_aggregation(get_bw_index(mod_id,CC_id), + eNB_UE_stats->DL_cqi[0], + format2A); + break; + default: + LOG_W(MAC,"Unsupported transmission mode %d\n", mac_xface->get_transmission_mode(mod_id,CC_id,rnti)); + aggregation = 2; } - + if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated CCE_allocation_infeasible(mod_id, CC_id, 0, subframe, aggregation, rnti)) { LOG_D(MAC,"[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", @@ -1160,6 +1099,7 @@ flexran_schedule_ue_spec_common(mid_t mod_id, flexran_get_harq(mod_id, CC_id, UE_id, frame, subframe, &harq_pid, &round); sdu_length_total=0; mcs = cqi_to_mcs[flexran_get_ue_wcqi(mod_id, UE_id)]; + // LOG_I(FLEXRAN_AGENT, "The MCS is %d\n", mcs); mcs = cmin(mcs,flexran_slice_maxmcs(slice_id)); #ifdef EXMIMO @@ -1192,9 +1132,10 @@ flexran_schedule_ue_spec_common(mid_t mod_id, dl_dci->harq_process = harq_pid; /* process retransmission */ - if (round > 0) { + LOG_D(FLEXRAN_AGENT, "There was a retransmission just now and the round was %d\n", round); + if (flexran_get_duplex_mode(mod_id, CC_id) == PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { UE_list->UE_template[CC_id][UE_id].DAI++; update_ul_dci(mod_id, CC_id, rnti, UE_list->UE_template[CC_id][UE_id].DAI); @@ -1237,8 +1178,6 @@ flexran_schedule_ue_spec_common(mid_t mod_id, } nb_available_rb -= nb_rb; - aggregation = process_ue_cqi(mod_id, UE_id); - PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; @@ -1267,15 +1206,16 @@ flexran_schedule_ue_spec_common(mid_t mod_id, //TBS = mac_xface->get_TBS(eNB_UE_stats->DL_cqi[0]<<1,nb_available_rb); TBS = mac_xface->get_TBS_DL(mcs, nb_available_rb); dci_tbs = TBS; - + LOG_D(FLEXRAN_AGENT, "TBS is %d\n", TBS); + // check first for RLC data on DCCH // add the length for all the control elements (timing adv, drx, etc) : header + payload - ta_len = (ue_sched_ctl->ta_update!=0) ? 2 : 0; + ta_len = (ue_sched_ctl->ta_update != 0) ? 2 : 0; dl_data[num_ues_added]->n_ce_bitmap = 2; - dl_data[num_ues_added]->ce_bitmap = (uint32_t *) malloc(sizeof(uint32_t) * 2); - + dl_data[num_ues_added]->ce_bitmap = (uint32_t *) calloc(2, sizeof(uint32_t)); + if (ta_len > 0) { ce_flags |= PROTOCOL__FLEX_CE_TYPE__FLPCET_TA; } @@ -1288,9 +1228,11 @@ flexran_schedule_ue_spec_common(mid_t mod_id, // TODO : Need to prioritize DRBs // Loop through the UE logical channels (DCCH, DCCH1, DTCH for now) + header_len = 0; + header_len_last = 0; + sdu_length_total = 0; for (j = 1; j < NB_RB_MAX; j++) { - header_len+=3; - + header_len += 3; // Need to see if we have space for data from this channel if (dci_tbs - ta_len - header_len - sdu_length_total > 0) { LOG_D(MAC, "[TEST]Requested %d bytes from RLC buffer on channel %d during first call\n", dci_tbs-ta_len-header_len); @@ -1302,15 +1244,19 @@ flexran_schedule_ue_spec_common(mid_t mod_id, ENB_FLAG_YES, MBMS_FLAG_NO, j, - (dci_tbs-ta_len-header_len)); // transport block set size + (dci_tbs - ta_len - header_len - sdu_length_total)); // transport block set size //If data are available in channel j if (rlc_status.bytes_in_buffer > 0) { LOG_D(MAC, "[TEST]Have %d bytes in DCCH buffer during first call\n", rlc_status.bytes_in_buffer); //Fill in as much as possible - data_to_request = cmin(dci_tbs-ta_len-header_len, rlc_status.bytes_in_buffer); + data_to_request = cmin(dci_tbs - ta_len - header_len - sdu_length_total, rlc_status.bytes_in_buffer); + LOG_D(FLEXRAN_AGENT, "Will request %d bytes from channel %d\n", data_to_request, j); if (data_to_request < 128) { //The header will be one byte less header_len--; + header_len_last = 2; + } else { + header_len_last = 3; } /* if (j == 1 || j == 2) { data_to_request+=0; @@ -1350,17 +1296,29 @@ flexran_schedule_ue_spec_common(mid_t mod_id, dl_data[num_ues_added]->rlc_pdu[i] = rlc_pdus[i]; } + if (header_len == 0) { + LOG_D(FLEXRAN_AGENT, "Header was empty\n"); + header_len_last = 0; + } + // there is a payload - if (( dl_data[num_ues_added]->n_rlc_pdu > 0)) { + if ((dl_data[num_ues_added]->n_rlc_pdu > 0)) { // Now compute number of required RBs for total sdu length // Assume RAH format 2 // adjust header lengths - - if (header_len == 2 || header_len == 3) { //Only one SDU, remove length field - header_len = 1; - } else { //Remove length field from the last SDU - header_len--; + LOG_D(FLEXRAN_AGENT, "We have %d bytes to transfer\n", sdu_length_total); + if (header_len != 0) { + LOG_D(FLEXRAN_AGENT, "Header length was %d ", header_len); + header_len_last--; + header_len -= header_len_last; + LOG_D(FLEXRAN_AGENT, "so we resized it to %d\n", header_len); } + + /* if (header_len == 2 || header_len == 3) { //Only one SDU, remove length field */ + /* header_len = 1; */ + /* } else { //Remove length field from the last SDU */ + /* header_len--; */ + /* } */ mcs_tmp = mcs; if (mcs_tmp == 0) { @@ -1434,8 +1392,8 @@ flexran_schedule_ue_spec_common(mid_t mod_id, dci_tbs = TBS; mcs = mcs_tmp; - - aggregation = process_ue_cqi(mod_id,UE_id); + LOG_D(FLEXRAN_AGENT, "Final mcs was %d\n", mcs); + dl_dci->has_aggr_level = 1; dl_dci->aggr_level = aggregation; @@ -1451,8 +1409,7 @@ flexran_schedule_ue_spec_common(mid_t mod_id, // do PUCCH power control // this is the normalized RX power normalized_rx_power = flexran_get_p0_pucch_dbm(mod_id,UE_id, CC_id); //eNB_UE_stats->Po_PUCCH_dBm; - target_rx_power = flexran_get_p0_nominal_pucch(mod_id, CC_id) + 10; //mac_xface->get_target_pucch_rx_power(mod_id, CC_id) + 10; - + target_rx_power = flexran_get_p0_nominal_pucch(mod_id, CC_id) + 20; //mac_xface->get_target_pucch_rx_power(mod_id, CC_id) + 20; // this assumes accumulated tpc // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame*10+UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; @@ -1460,8 +1417,8 @@ flexran_schedule_ue_spec_common(mid_t mod_id, if (((framex10psubframe+10)<=(frame*10+subframe)) || //normal case ((framex10psubframe>(frame*10+subframe)) && (((10240-framex10psubframe+frame*10+subframe)>=10)))) //frame wrap-around if (flexran_get_p0_pucch_status(mod_id, UE_id, CC_id) == 1) { - flexran_update_p0_pucch(mod_id, UE_id, CC_id); - + flexran_update_p0_pucch(mod_id, UE_id, CC_id); + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frame; UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframe; if (normalized_rx_power>(target_rx_power+1)) { diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index e7bfb348ee7879efa59ad2193c7a3019db86ff74..6e73e353f019954e954e757ac10b4984e48d2731 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -68,7 +68,7 @@ /* this function checks that get_eNB_UE_stats returns * a non-NULL pointer for all CCs for a given UE */ -static int phy_stats_exist(module_id_t Mod_id, int rnti) +int phy_stats_exist(module_id_t Mod_id, int rnti) { int CC_id; for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) @@ -1081,8 +1081,7 @@ void dlsch_scheduler_pre_processor_allocate (module_id_t Mod_id, void ulsch_scheduler_pre_processor(module_id_t module_idP, int frameP, sub_frame_t subframeP, - uint16_t *first_rb, - uint8_t aggregation) + uint16_t *first_rb) { int16_t i; diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 5da2367cefa11c66c32aa45d13da8e902a132afb..77a60794cc7fd039650379369b8e83330b3e99f4 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -320,7 +320,7 @@ rnti_t UE_RNTI (module_id_t module_idP, int UE_id); int UE_PCCID (module_id_t module_idP, int UE_id); uint8_t find_active_UEs (module_id_t module_idP); boolean_t is_UE_active (module_id_t module_idP, int UE_id); -uint8_t process_ue_cqi (module_id_t module_idP, int UE_id); +uint8_t get_aggregation (uint8_t bw_index, uint8_t cqi, uint8_t dci_fmt); int8_t find_active_UEs_with_traffic(module_id_t module_idP); @@ -531,11 +531,12 @@ int UE_PCCID(module_id_t mod_idP,int ue_idP); rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP); -void ulsch_scheduler_pre_processor(module_id_t module_idP, int frameP, sub_frame_t subframeP, uint16_t *first_rb, uint8_t aggregattion); +void ulsch_scheduler_pre_processor(module_id_t module_idP, int frameP, sub_frame_t subframeP, uint16_t *first_rb); void store_ulsch_buffer(module_id_t module_idP, int frameP, sub_frame_t subframeP); void sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP); void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subframeP,uint16_t *first_rb); void adjust_bsr_info(int buffer_occupancy, uint16_t TBS, UE_TEMPLATE *UE_template); +int phy_stats_exist(module_id_t Mod_id, int rnti); /*! \fn UE_L2_state_t ue_scheduler(const module_id_t module_idP,const frame_t frameP, const sub_frame_t subframe, const lte_subframe_t direction,const uint8_t eNB_index) \brief UE scheduler where all the ue background tasks are done. This function performs the following: 1) Trigger PDCP every 5ms 2) Call RRC for link status return to PHY3) Perform SR/BSR procedures for scheduling feedback 4) Perform PHR procedures. @@ -696,6 +697,8 @@ uint32_t allocate_prbs_sub(int nb_rb, uint8_t *rballoc); void update_ul_dci(module_id_t module_idP,uint8_t CC_id,rnti_t rnti,uint8_t dai); +int get_bw_index(module_id_t module_id, uint8_t CC_id); + int get_min_rb_unit(module_id_t module_idP, uint8_t CC_id); /* \brief Generate header for DL-SCH. This function parses the desired control elements and sdus and generates the header as described diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c index b453b5cca8529ed75aa50bbdbc1cd7cfa11b10d1..2de22c067affe4fae4833400f5d735e77de4d9c0 100644 --- a/openair2/LAYER2/MAC/rar_tools.c +++ b/openair2/LAYER2/MAC/rar_tools.c @@ -97,7 +97,7 @@ unsigned short fill_rar( eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].timing_offset /= 16; //T_A = N_TA/16, where N_TA should be on a 30.72Msps rar[0] = (uint8_t)(eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].timing_offset>>(2+4)); // 7 MSBs of timing advance + divide by 4 rar[1] = (uint8_t)(eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].timing_offset<<(4-2))&0xf0; // 4 LSBs of timing advance + divide by 4 - rballoc = mac_xface->computeRIV(N_RB_UL,1,1); // first PRB only for UL Grant + rballoc = mac_xface->computeRIV(N_RB_UL,26,1); // first PRB only for UL Grant rar[1] |= (rballoc>>7)&7; // Hopping = 0 (bit 3), 3 MSBs of rballoc rar[2] = ((uint8_t)(rballoc&0xff))<<1; // 7 LSBs of rballoc mcs = 10; diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/vars.h index 236439c6e5b732fff57292c5f3e71326974c0ed8..edd8548e642f02c8722207cad6fb15ce219e6989 100644 --- a/openair2/LAYER2/MAC/vars.h +++ b/openair2/LAYER2/MAC/vars.h @@ -55,6 +55,36 @@ const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE] = {0,10,13,16,19,23,29,35,43,5 1067031,1312097,1613447,1984009,2439678,3000000, 6000000}; +//#define MAX_SIZE_OF_AGG3 576 +//#define MAX_SIZE_OF_AGG2 288 +//#define MAX_SIZE_OF_AGG1 144 +//#define MAX_SIZE_OF_AGG0 72 + +/* + * If the CQI is low, then scheduler will use a higher aggregation level and lower aggregation level otherwise + * this is also dependent to transmission mode, where an offset could be defined + */ +// the follwoing three tables are calibrated for TXMODE 1 and 2 +const uint8_t cqi2fmt0_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE]= { + {3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, // 1.4_DCI0_CRC_Size= 37 bits + //{3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0}, // 5_DCI0_CRC_SIZE = 41 + {3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, // 5_DCI0_CRC_SIZE = 41 + {3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0}, // 10_DCI0_CRC_SIZE = 43 + {3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0} // 20_DCI0_CRC_SIZE = 44 +}; +const uint8_t cqi2fmt1x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE]= { + {3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, // 1.4_DCI0_CRC_Size < 38 bits + {3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, // 5_DCI0_CRC_SIZE < 43 + {3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0}, // 10_DCI0_CRC_SIZE < 47 + {3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0} // 20_DCI0_CRC_SIZE < 55 +}; +const uint8_t cqi2fmt2x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE]= { + {3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, // 1.4_DCI0_CRC_Size= 47 bits + {3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, // 5_DCI0_CRC_SIZE = 55 + {3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0}, // 10_DCI0_CRC_SIZE = 59 + {3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0} // 20_DCI0_CRC_SIZE = 64 +}; + //uint32_t EBSR_Level[63]={0,10,13,16,19,23,29,35,43,53,65,80,98,120,147,181}; MAC_xface *mac_xface; diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c index c137d38cc08ac658255a614014eba274dfd8a3ca..8a8aaf73ba06e5b1f27a86db094d89531b8c8440 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LITE/rrc_UE.c @@ -3131,9 +3131,13 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 ) sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig ); LOG_I( RRC, "radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission : %d\n", sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission ); - //LOG_I( RRC, "radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts : %ld\n", - /* TODO: check that it's okay to access [0] */ - // sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts[0] ); +#if 0 + /* TODO: test this - commented for the moment */ + if (sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts) + LOG_I( RRC, "radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts : %ld\n", + /* TODO: check that it's okay to access [0] */ + sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts[0] ); +#endif } // uplinkPowerControlCommon diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c index 898382cf6a480ebea27429f4c6a1f5592c632140..c151ab11ff9464918b33f75871edfba8d0862fea 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c @@ -197,6 +197,7 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam int nblocks = nsamps; int bytes_sent = 0; + eth_state_t *eth = (eth_state_t*)device->priv; @@ -216,7 +217,6 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam } eth->tx_nsamps = nblocks; - bytes_sent = sendto(eth->sockfd, buff[0], packet_size, @@ -245,6 +245,8 @@ int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, voi //sendto_flag|=flags; eth->tx_nsamps=nsamps; + + for (i=0;i<cc;i++) { /* buff[i] points to the position in tx buffer where the payload to be sent is buff2 points to the position in tx buffer where the packet header will be placed */ @@ -264,7 +266,8 @@ int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, voi *(uint16_t *)(buff2 + sizeof(uint16_t)) = 1+(i<<1); *(openair0_timestamp *)(buff2 + sizeof(int32_t)) = timestamp; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TX_SEQ_NUM, pck_seq_num); - + + while(bytes_sent < UDP_PACKET_SIZE_BYTES(nsamps)) { #if DEBUG printf("------- TX ------: buff2 current position=%d remaining_bytes=%d bytes_sent=%d \n", diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c index 6f93ba4853d3fa209246871d57abf65f62f3493a..d30f8faed827d75febd8610300f9d674a35f902b 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c @@ -84,6 +84,12 @@ int trx_eth_start(openair0_device *device) { } else { if(eth_get_dev_conf_udp(device)!=0) return -1; } + + /* adjust MTU wrt number of samples per packet */ + /*if(ethernet_tune (device,MTU_SIZE,UDP_IF4p5_PRACH_SIZE_BYTES)!=0) return -1; + + if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1;*/ + } else if (eth->flags == ETH_RAW_IF5_MOBIPASS) { printf("Setting ETHERNET to RAW_IF5_MODE\n"); if (eth_socket_init_raw(device)!=0) return -1; @@ -97,7 +103,12 @@ int trx_eth_start(openair0_device *device) { if(eth_set_dev_conf_udp(device)!=0) return -1; } else { if(eth_get_dev_conf_udp(device)!=0) return -1; - } + } + + /* adjust MTU wrt number of samples per packet */ + if(ethernet_tune (device,MTU_SIZE,UDP_IF4p5_PRACH_SIZE_BYTES)!=0) return -1; + + if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1; } /* apply additional configuration */ if(ethernet_tune (device, SND_BUF_SIZE,2000000000)!=0) return -1; diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h b/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h index 5fdb962b09019470b6f5840f5bbacd890df1b2ee..f4d6d6df1c616aa61c004df8fa4239504609d199 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h @@ -47,6 +47,11 @@ #define ETH_RAW_IF5_MOBIPASS 4 #endif +// COMMOM HEADER LENGTHS + +#define UDP_HEADER_SIZE_BYTES 8 +#define IPV4_HEADER_SIZE_BYTES 60 // This is the maximum IPv4 header length + // Time domain RRH packet sizes #define MAC_HEADER_SIZE_BYTES (sizeof(struct ether_header)) #define MAX_PACKET_SEQ_NUM(spp,spf) (spf/spp) @@ -56,17 +61,17 @@ // Packet sizes for IF4p5 interface format #define DATA_BLOCK_SIZE_BYTES(scaled_nblocks) (sizeof(uint16_t)*scaled_nblocks) -#define PRACH_HARD_CODED_NUM_SAMPLES (839*2) +#define PRACH_HARD_CODED_NUM_SAMPLES (839*4) #define PRACH_BLOCK_SIZE_BYTES (sizeof(int16_t)*PRACH_HARD_CODED_NUM_SAMPLES) // FIX hard coded prach size #define RAW_IF4p5_PDLFFT_SIZE_BYTES(nblocks) (MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t + DATA_BLOCK_SIZE_BYTES(nblocks)) #define RAW_IF4p5_PULFFT_SIZE_BYTES(nblocks) (MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t + DATA_BLOCK_SIZE_BYTES(nblocks)) #define RAW_IF4p5_PULTICK_SIZE_BYTES (MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t) #define RAW_IF4p5_PRACH_SIZE_BYTES (MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t + PRACH_BLOCK_SIZE_BYTES) -#define UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks) (sizeof_IF4p5_header_t + DATA_BLOCK_SIZE_BYTES(nblocks)) -#define UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks) (sizeof_IF4p5_header_t + DATA_BLOCK_SIZE_BYTES(nblocks)) -#define UDP_IF4p5_PULTICK_SIZE_BYTES (sizeof_IF4p5_header_t) -#define UDP_IF4p5_PRACH_SIZE_BYTES (sizeof_IF4p5_header_t + PRACH_BLOCK_SIZE_BYTES) +#define UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks) (UDP_HEADER_SIZE_BYTES + IPV4_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t + DATA_BLOCK_SIZE_BYTES(nblocks)) +#define UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks) (UDP_HEADER_SIZE_BYTES + IPV4_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t + DATA_BLOCK_SIZE_BYTES(nblocks)) +#define UDP_IF4p5_PULTICK_SIZE_BYTES (UDP_HEADER_SIZE_BYTES + IPV4_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t) +#define UDP_IF4p5_PRACH_SIZE_BYTES (UDP_HEADER_SIZE_BYTES + IPV4_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t + PRACH_BLOCK_SIZE_BYTES) // Mobipass packet sizes #define RAW_IF5_MOBIPASS_BLOCK_SIZE_BYTES 1280 diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.25PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.25PRB.usrpb210.conf new file mode 100644 index 0000000000000000000000000000000000000000..c4c125a394a6b9a42c289a4eaa54ee6147997887 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.25PRB.usrpb210.conf @@ -0,0 +1,174 @@ +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"; + + ////////// 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 = 25; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 120; + 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 = -24; + 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 = -104; + 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 = "127.0.0.3"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + ENB_INTERFACE_NAME_FOR_S1_MME = "lo"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.2/24"; + + ENB_INTERFACE_NAME_FOR_S1U = "lo"; + ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.5/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + 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 ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + } +); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.generic.oaisim.local_no_mme.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.generic.oaisim.local_no_mme.conf index a79cb2cae6301060a579ffc143defc2bb61d7d60..8db3e2304dfd2f05afeca060a4bbf9866543fb03 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.generic.oaisim.local_no_mme.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.generic.oaisim.local_no_mme.conf @@ -34,7 +34,7 @@ eNBs = downlink_frequency = 2680000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; - N_RB_DL = 25; + N_RB_DL = 50; Nid_cell_mbsfn = 0; nb_antenna_ports = 1; nb_antennas_tx = 1; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.100PRB.usrpb210.conf similarity index 99% rename from targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf rename to targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.100PRB.usrpb210.conf index 4ad5767ce9a8343a5c117b8bcf1001636b4b12dc..cdaf13e01a6c0aa5d0d676069e1f550a70f20f19 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.100PRB.usrpb210.conf @@ -34,7 +34,7 @@ eNBs = downlink_frequency = 2685000000L; uplink_frequency_offset = -120000000; Nid_cell = 0; - N_RB_DL = 50; + N_RB_DL = 100; Nid_cell_mbsfn = 0; nb_antenna_ports = 1; nb_antennas_tx = 1; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.lo.conf similarity index 98% rename from targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf rename to targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.lo.conf index f9ebec3ab53561789e5cbf9b81130c0cf7640c38..5aad9973bb01be60aaf061dc896c08d18725811a 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.lo.conf @@ -156,9 +156,9 @@ eNBs = rrh_gw_config = ( { - local_if_name = "eth0"; - remote_address = "10.10.10.60"; - local_address = "10.10.10.215"; + local_if_name = "lo"; + remote_address = "127.0.0.1"; + local_address = "127.0.0.2"; local_port = 50000; #for raw option local port must be the same to remote remote_port = 50000; rrh_gw_active = "yes"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.usrpb210.conf new file mode 100644 index 0000000000000000000000000000000000000000..8572fc69175e8fce82a5144d495b5c108aa54129 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.usrpb210.conf @@ -0,0 +1,191 @@ +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 = "92"; + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "NGFI_RCC_IF4p5"; + 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 = 2660000000L; + uplink_frequency_offset = -120000000; + Nid_cell = 0; + N_RB_DL = 25; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + 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 = -24; + 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 = -104; + 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 = "eth0"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.19/24"; + ENB_INTERFACE_NAME_FOR_S1U = "eth0"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.19/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + rrh_gw_config = ( + { + local_if_name = "em2"; + remote_address = "10.10.10.157"; + local_address = "10.10.10.19"; + local_port = 50000; #for raw option local port must be the same to remote + remote_port = 50000; + rrh_gw_active = "yes"; + tr_preference = "udp_if4p5"; + rf_preference = "usrp_b200"; + iq_txshift = 4; + tx_sample_advance = 80; + tx_scheduling_advance = 9; + } + ); + + 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 ="info"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + } +); 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 new file mode 100644 index 0000000000000000000000000000000000000000..918e7825cc4cefb0cba5327a07cb02dd0179a50b --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf @@ -0,0 +1,191 @@ +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"; + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "NGFI_RCC_IF4p5"; + 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 = 50; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + 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 = "127.0.0.3"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + ENB_INTERFACE_NAME_FOR_S1_MME = "lo"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.2/24"; + ENB_INTERFACE_NAME_FOR_S1U = "lo"; + ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.5/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + rrh_gw_config = ( + { + local_if_name = "lo"; + remote_address = "127.0.0.1"; + local_address = "127.0.0.2"; + local_port = 50000; #for raw option local port must be the same to remote + remote_port = 50000; + rrh_gw_active = "yes"; + tr_preference = "udp_if4p5"; + rf_preference = "usrp_b200"; + iq_txshift = 4; + tx_sample_advance = 80; + tx_scheduling_advance = 9; + } + ); + + 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 ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + } +); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.usrpb210.conf new file mode 100644 index 0000000000000000000000000000000000000000..43385eefb974f235594eb0336ad674e908614f24 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.usrpb210.conf @@ -0,0 +1,193 @@ +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 = "92"; + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "NGFI_RCC_IF4p5"; + 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 = 2660000000L; + uplink_frequency_offset = -120000000; + Nid_cell = 0; + N_RB_DL = 50; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + 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 = -24; + 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 = -104; + 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 = "eth0"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.19/24"; + ENB_INTERFACE_NAME_FOR_S1U = "eth0"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.19/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + rrh_gw_config = ( + { + local_if_name = "em2"; + remote_address = "10.10.10.157"; + local_address = "10.10.10.19"; + local_port = 50000; #for raw option local port must be the same to remote + remote_port = 50000; + rrh_gw_active = "yes"; + tr_preference = "udp_if4p5"; + rf_preference = "usrp_b200"; + iq_txshift = 4; + tx_sample_advance = 80; + tx_scheduling_advance = 9; + } + ); + + 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 ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + } +); + diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.100PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.100PRB.usrpb210.conf new file mode 100644 index 0000000000000000000000000000000000000000..ee2b1cb021f7ee64a6989e3f3bc129d0e39c2b21 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.100PRB.usrpb210.conf @@ -0,0 +1,195 @@ +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"; + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "eNodeB_3GPP_BBU"; + 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 = 2660000000L; + 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; + 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 = -29; + 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 = -90; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -96; + 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 = "127.0.0.3"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + ENB_INTERFACE_NAME_FOR_S1_MME = "lo"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.2/24"; + ENB_INTERFACE_NAME_FOR_S1U = "lo"; + ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.4/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + rrh_gw_config = ( + { + local_if_name = "eth2"; + remote_address = "10.10.10.60"; + local_address = "10.10.10.215"; + local_port = 50000; #for raw option local port must be the same to remote + remote_port = 50000; + rrh_gw_active = "yes"; + tr_preference = "udp"; + rf_preference = "usrp_b200"; + iq_txshift = 4; + tx_sample_advance = 80; + tx_scheduling_advance = 9; + } + ); + + 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 ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + } +); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.usrpb210.conf similarity index 100% rename from targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.conf rename to targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.25PRB.usrpb210.conf diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.50PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.50PRB.usrpb210.conf similarity index 100% rename from targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.50PRB.conf rename to targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if5.50PRB.usrpb210.conf diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.oaisim.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.oaisim.conf new file mode 100644 index 0000000000000000000000000000000000000000..26ecfb64f2b23b25d6d87abca1cee28c1789aa52 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.25PRB.oaisim.conf @@ -0,0 +1,193 @@ +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"; + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "NGFI_RRU_IF4p5"; + 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 = 25; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 120; + 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 = -29; + 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 = -95; + 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 = -104; + 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.11"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + ENB_INTERFACE_NAME_FOR_S1_MME = "eth3"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.215/24"; + ENB_INTERFACE_NAME_FOR_S1U = "eth3"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.215/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + rrh_gw_config = ( + { + local_if_name = "lo"; + remote_address = "127.0.0.2"; + local_address = "127.0.0.1"; + local_port = 50000; #for raw option local port must be the same to remote + remote_port = 50000; + rrh_gw_active = "yes"; + tr_preference = "udp_if4p5"; + rf_preference = "usrp_b200"; + iq_txshift = 4; + tx_sample_advance = 80; + tx_scheduling_advance = 9; + } + ); + + 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 ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + } +); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.oaisim.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.oaisim.conf new file mode 100644 index 0000000000000000000000000000000000000000..b6cd51ec965f7b01af0f3557f596e4e4f61d7018 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if4p5.50PRB.oaisim.conf @@ -0,0 +1,193 @@ +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"; + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "NGFI_RRU_IF4p5"; + 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 = 50; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 120; + 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 = -95; + 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 = -104; + 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.11"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + ENB_INTERFACE_NAME_FOR_S1_MME = "eth3"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.215/24"; + ENB_INTERFACE_NAME_FOR_S1U = "eth3"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.215/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + rrh_gw_config = ( + { + local_if_name = "lo"; + remote_address = "127.0.0.2"; + local_address = "127.0.0.1"; + local_port = 50000; #for raw option local port must be the same to remote + remote_port = 50000; + rrh_gw_active = "yes"; + tr_preference = "udp_if4p5"; + rf_preference = "usrp_b200"; + iq_txshift = 4; + tx_sample_advance = 80; + tx_scheduling_advance = 9; + } + ); + + 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 ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + } +); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if5.100PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if5.100PRB.usrpb210.conf new file mode 100644 index 0000000000000000000000000000000000000000..f6bbe9ff58a08e46b04b8ca2f4cce10f996d25de --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if5.100PRB.usrpb210.conf @@ -0,0 +1,190 @@ +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 = "92"; + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "NGFI_RRU_IF5"; + 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 = 2660000000L; + uplink_frequency_offset = -120000000; + Nid_cell = 0; + N_RB_DL = 100; + Nid_cell_mbsfn = 0; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + 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 = -29; + 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 = -90; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -96; + 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; + + } + ); + + + 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.11"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + ENB_INTERFACE_NAME_FOR_S1_MME = "eth3"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.215/24"; + ENB_INTERFACE_NAME_FOR_S1U = "eth3"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.215/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + rrh_gw_config = ( + { + local_if_name = "eth0"; + remote_address = "90:e2:ba:c5:fc:04"; + local_address = "00:13:95:1f:a0:af"; + local_port = 50000; #for raw option local port must be the same to remote + remote_port = 50000; + rrh_gw_active = "yes"; + tr_preference = "raw_if5"; + rf_preference = "usrp_b200"; + iq_txshift = 4; + tx_sample_advance = 80; + tx_scheduling_advance = 9; + } + ); + + 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 ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + } +); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.50PRB.if5.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if5.50PRB.usrpb210.conf similarity index 100% rename from targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.50PRB.if5.usrpb210.conf rename to targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.band7.tm1.if5.50PRB.usrpb210.conf diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 0605dff2ab5607123d9dc5f73b0c1c6ec47ecd36..8a84a5466f398907b7a62a18b861e9e9bc9f9beb 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -29,34 +29,8 @@ * \note * \warning */ -#define _GNU_SOURCE -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <sched.h> -#include <linux/sched.h> -#include <signal.h> -#include <execinfo.h> -#include <getopt.h> -#include <sys/sysinfo.h> -#include "rt_wrapper.h" - -#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all - -#include "assertions.h" -#include "msc.h" - -#include "PHY/types.h" - -#include "PHY/defs.h" -#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all -//#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all -#include "../../ARCH/COMMON/common_lib.h" +#include "lte-softmodem.h" //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all @@ -92,14 +66,6 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "UTIL/OTG/otg_extern.h" #endif -#if defined(ENABLE_ITTI) -# if defined(ENABLE_USE_MME) -# include "s1ap_eNB.h" -#ifdef PDCP_USE_NETLINK -# include "SIMULATION/ETH_TRANSPORT/proto.h" -#endif -# endif -#endif #include "T.h" @@ -107,28 +73,15 @@ unsigned short config_frames[4] = {2,9,11,13}; //#define USRP_DEBUG 1 struct timing_info_t { - //unsigned int frame, hw_slot, last_slot, next_slot; - RTIME time_min, time_max, time_avg, time_last, time_now; - //unsigned int mbox0, mbox1, mbox2, mbox_target; - unsigned int n_samples; + //unsigned int frame, hw_slot, last_slot, next_slot; + RTIME time_min, time_max, time_avg, time_last, time_now; + //unsigned int mbox0, mbox1, mbox2, mbox_target; + unsigned int n_samples; } timing_info; // Fix per CC openair rf/if device update // extern openair0_device openair0; -#if defined(ENABLE_ITTI) -extern volatile int start_eNB; -extern volatile int start_UE; -#endif -extern volatile int oai_exit; - -extern openair0_config_t openair0_cfg[MAX_CARDS]; - -extern pthread_cond_t sync_cond; -extern pthread_mutex_t sync_mutex; -extern int sync_var; - -extern int transmission_mode; //pthread_t main_eNB_thread; @@ -148,12 +101,11 @@ static int time_offset[4] = {0,0,0,0}; * performances) */ static struct { - pthread_mutex_t mutex_phy_proc_tx; - pthread_cond_t cond_phy_proc_tx; - volatile uint8_t phy_proc_CC_id; + pthread_mutex_t mutex_phy_proc_tx; + pthread_cond_t cond_phy_proc_tx; + volatile uint8_t phy_proc_CC_id; } sync_phy_proc; -extern double cpuf; void exit_fun(const char* s); @@ -162,432 +114,429 @@ void stop_eNB(int nb_inst); static inline void thread_top_init(char *thread_name, - int affinity, - uint64_t runtime, - uint64_t deadline, - uint64_t period) { + int affinity, + uint64_t runtime, + uint64_t deadline, + uint64_t period) { - MSC_START_USE(); + MSC_START_USE(); #ifdef DEADLINE_SCHEDULER - struct sched_attr attr; + struct sched_attr attr; - unsigned int flags = 0; + unsigned int flags = 0; - attr.size = sizeof(attr); - attr.sched_flags = 0; - attr.sched_nice = 0; - attr.sched_priority = 0; + attr.size = sizeof(attr); + attr.sched_flags = 0; + attr.sched_nice = 0; + attr.sched_priority = 0; - attr.sched_policy = SCHED_DEADLINE; - attr.sched_runtime = runtime; - attr.sched_deadline = deadline; - attr.sched_period = period; + attr.sched_policy = SCHED_DEADLINE; + attr.sched_runtime = runtime; + attr.sched_deadline = deadline; + attr.sched_period = period; - if (sched_setattr(0, &attr, flags) < 0 ) { - perror("[SCHED] eNB tx thread: sched_setattr failed\n"); - exit(1); - } + if (sched_setattr(0, &attr, flags) < 0 ) { + perror("[SCHED] eNB tx thread: sched_setattr failed\n"); + exit(1); + } #else //LOW_LATENCY - int policy, s, j; - struct sched_param sparam; - char cpu_affinity[1024]; - cpu_set_t cpuset; + int policy, s, j; + struct sched_param sparam; + char cpu_affinity[1024]; + cpu_set_t cpuset; - /* Set affinity mask to include CPUs 1 to MAX_CPUS */ - /* CPU 0 is reserved for UHD threads */ - /* CPU 1 is reserved for all RX_TX threads */ - /* Enable CPU Affinity only if number of CPUs >2 */ - CPU_ZERO(&cpuset); + /* Set affinity mask to include CPUs 1 to MAX_CPUS */ + /* CPU 0 is reserved for UHD threads */ + /* CPU 1 is reserved for all RX_TX threads */ + /* Enable CPU Affinity only if number of CPUs >2 */ + CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY - if (get_nprocs() > 2) - { - if (affinity == 0) - CPU_SET(0,&cpuset); - else - for (j = 1; j < get_nprocs(); j++) - CPU_SET(j, &cpuset); - s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - if (s != 0) - { - perror( "pthread_setaffinity_np"); - exit_fun("Error setting processor affinity"); + if (get_nprocs() > 2) { + if (affinity == 0) + CPU_SET(0,&cpuset); + else + for (j = 1; j < get_nprocs(); j++) + CPU_SET(j, &cpuset); + s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + if (s != 0) { + perror( "pthread_setaffinity_np"); + exit_fun("Error setting processor affinity"); + } } - } #endif //CPU_AFFINITY - /* Check the actual affinity mask assigned to the thread */ - s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - if (s != 0) { - perror( "pthread_getaffinity_np"); - exit_fun("Error getting processor affinity "); - } - memset(cpu_affinity,0,sizeof(cpu_affinity)); - for (j = 0; j < CPU_SETSIZE; j++) - if (CPU_ISSET(j, &cpuset)) { - char temp[1024]; - sprintf (temp, " CPU_%d", j); - strcat(cpu_affinity, temp); + /* Check the actual affinity mask assigned to the thread */ + s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + if (s != 0) { + perror( "pthread_getaffinity_np"); + exit_fun("Error getting processor affinity "); + } + memset(cpu_affinity,0,sizeof(cpu_affinity)); + for (j = 0; j < CPU_SETSIZE; j++) + if (CPU_ISSET(j, &cpuset)) { + char temp[1024]; + sprintf (temp, " CPU_%d", j); + strcat(cpu_affinity, temp); + } + + memset(&sparam, 0, sizeof(sparam)); + sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); + policy = SCHED_FIFO ; + + s = pthread_setschedparam(pthread_self(), policy, &sparam); + if (s != 0) { + perror("pthread_setschedparam : "); + exit_fun("Error setting thread priority"); + } + + s = pthread_getschedparam(pthread_self(), &policy, &sparam); + if (s != 0) { + perror("pthread_getschedparam : "); + exit_fun("Error getting thread priority"); } - memset(&sparam, 0, sizeof(sparam)); - sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); - policy = SCHED_FIFO ; - - s = pthread_setschedparam(pthread_self(), policy, &sparam); - if (s != 0) { - perror("pthread_setschedparam : "); - exit_fun("Error setting thread priority"); - } - - s = pthread_getschedparam(pthread_self(), &policy, &sparam); - if (s != 0) { - perror("pthread_getschedparam : "); - exit_fun("Error getting thread priority"); - } - - LOG_I(HW, "[SCHED][eNB] %s started on CPU %d TID %ld, sched_policy = %s , priority = %d, CPU Affinity=%s \n",thread_name,sched_getcpu(),gettid(), - (policy == SCHED_FIFO) ? "SCHED_FIFO" : - (policy == SCHED_RR) ? "SCHED_RR" : - (policy == SCHED_OTHER) ? "SCHED_OTHER" : - "???", - sparam.sched_priority, cpu_affinity ); + LOG_I(HW, "[SCHED][eNB] %s started on CPU %d TID %ld, sched_policy = %s , priority = %d, CPU Affinity=%s \n",thread_name,sched_getcpu(),gettid(), + (policy == SCHED_FIFO) ? "SCHED_FIFO" : + (policy == SCHED_RR) ? "SCHED_RR" : + (policy == SCHED_OTHER) ? "SCHED_OTHER" : + "???", + sparam.sched_priority, cpu_affinity ); #endif //LOW_LATENCY - mlockall(MCL_CURRENT | MCL_FUTURE); + mlockall(MCL_CURRENT | MCL_FUTURE); } static inline void wait_sync(char *thread_name) { - printf( "waiting for sync (%s)\n",thread_name); - pthread_mutex_lock( &sync_mutex ); - - while (sync_var<0) - pthread_cond_wait( &sync_cond, &sync_mutex ); - - pthread_mutex_unlock(&sync_mutex); - - printf( "got sync (%s)\n", thread_name); + printf( "waiting for sync (%s)\n",thread_name); + pthread_mutex_lock( &sync_mutex ); + + while (sync_var<0) + pthread_cond_wait( &sync_cond, &sync_mutex ); + + pthread_mutex_unlock(&sync_mutex); + + printf( "got sync (%s)\n", thread_name); } -void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) -{ - - int CC_id = phy_vars_eNB->proc.CC_id; - unsigned int aa,slot_offset; - //int dummy_tx_b[7680*4] __attribute__((aligned(32))); - int i, tx_offset; - //int slot_sizeF = (phy_vars_eNB->frame_parms.ofdm_symbol_size)* ((phy_vars_eNB->frame_parms.Ncp==1) ? 6 : 7); - int len; - //int slot_offset_F = (subframe<<1)*slot_sizeF; - - slot_offset = subframe*phy_vars_eNB->frame_parms.samples_per_tti; - - if ((subframe_select(&phy_vars_eNB->frame_parms,subframe)==SF_DL)|| - ((subframe_select(&phy_vars_eNB->frame_parms,subframe)==SF_S))) { - // LOG_D(HW,"Frame %d: Generating slot %d\n",frame,next_slot); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_OFDM_MODULATION,1); - - do_OFDM_mod_symbol(&phy_vars_eNB->common_vars, - 0, - subframe<<1, - &phy_vars_eNB->frame_parms, - phy_vars_eNB->do_precoding); - - // if S-subframe generate first slot only - if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL) { - do_OFDM_mod_symbol(&phy_vars_eNB->common_vars, - 0, - 1+(subframe<<1), - &phy_vars_eNB->frame_parms, - phy_vars_eNB->do_precoding); - } +void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_OFDM_MODULATION,0); - + int CC_id = phy_vars_eNB->proc.CC_id; + unsigned int aa,slot_offset; + //int dummy_tx_b[7680*4] __attribute__((aligned(32))); + int i, tx_offset; + //int slot_sizeF = (phy_vars_eNB->frame_parms.ofdm_symbol_size)* ((phy_vars_eNB->frame_parms.Ncp==1) ? 6 : 7); + int len; + //int slot_offset_F = (subframe<<1)*slot_sizeF; -/* - for (aa=0; aa<phy_vars_eNB->frame_parms.nb_antennas_tx; aa++) { - if (phy_vars_eNB->frame_parms.Ncp == EXTENDED) { - PHY_ofdm_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F], - dummy_tx_b, - phy_vars_eNB->frame_parms.ofdm_symbol_size, - 6, - phy_vars_eNB->frame_parms.nb_prefix_samples, - CYCLIC_PREFIX); - if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL) - PHY_ofdm_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F+slot_sizeF], - dummy_tx_b+(phy_vars_eNB->frame_parms.samples_per_tti>>1), - phy_vars_eNB->frame_parms.ofdm_symbol_size, - 6, - phy_vars_eNB->frame_parms.nb_prefix_samples, - CYCLIC_PREFIX); - } else { - normal_prefix_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F], - dummy_tx_b, - 7, - &(phy_vars_eNB->frame_parms)); - // if S-subframe generate first slot only - if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL) - normal_prefix_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F+slot_sizeF], - dummy_tx_b+(phy_vars_eNB->frame_parms.samples_per_tti>>1), - 7, - &(phy_vars_eNB->frame_parms)); - } - } */ - - for (aa=0; aa<phy_vars_eNB->frame_parms.nb_antennas_tx; aa++) { - // if S-subframe generate first slot only - if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_S) - len = phy_vars_eNB->frame_parms.samples_per_tti>>1; - else - len = phy_vars_eNB->frame_parms.samples_per_tti; - /* - for (i=0;i<len;i+=4) { - dummy_tx_b[i] = 0x100; - dummy_tx_b[i+1] = 0x01000000; - dummy_tx_b[i+2] = 0xff00; - dummy_tx_b[i+3] = 0xff000000; - }*/ - for (i=0; i<len; i++) { - tx_offset = (int)slot_offset+time_offset[aa]+i; - - - if (tx_offset<0) - tx_offset += LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; - - if (tx_offset>=(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti)) - tx_offset -= LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; - -/* ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[0] = ((short*)dummy_tx_b)[2*i]<<openair0_cfg[0].iq_txshift; - - ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[1] = ((short*)dummy_tx_b)[2*i+1]<<openair0_cfg[0].iq_txshift; */ - - ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[0] = ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[0]<<openair0_cfg[CC_id].iq_txshift; - - ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[1] = ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[1]<<openair0_cfg[CC_id].iq_txshift; - } - // if S-subframe switch to RX in second subframe - if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_S) { - for (i=0; i<len; i++) { - phy_vars_eNB->common_vars.txdata[0][aa][tx_offset++] = 0x00010001; - } - } - - if ((((phy_vars_eNB->frame_parms.tdd_config==0) || - (phy_vars_eNB->frame_parms.tdd_config==1) || - (phy_vars_eNB->frame_parms.tdd_config==2) || - (phy_vars_eNB->frame_parms.tdd_config==6)) && - (subframe==0)) || (subframe==5)) { - // turn on tx switch N_TA_offset before - //LOG_D(HW,"subframe %d, time to switch to tx (N_TA_offset %d, slot_offset %d) \n",subframe,phy_vars_eNB->N_TA_offset,slot_offset); - for (i=0; i<phy_vars_eNB->N_TA_offset; i++) { - tx_offset = (int)slot_offset+time_offset[aa]+i-phy_vars_eNB->N_TA_offset; - if (tx_offset<0) - tx_offset += LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; - - if (tx_offset>=(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti)) - tx_offset -= LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; - - phy_vars_eNB->common_vars.txdata[0][aa][tx_offset] = 0x00000000; - } - } + slot_offset = subframe*phy_vars_eNB->frame_parms.samples_per_tti; + + if ((subframe_select(&phy_vars_eNB->frame_parms,subframe)==SF_DL)|| + ((subframe_select(&phy_vars_eNB->frame_parms,subframe)==SF_S))) { + // LOG_D(HW,"Frame %d: Generating slot %d\n",frame,next_slot); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_OFDM_MODULATION,1); + + do_OFDM_mod_symbol(&phy_vars_eNB->common_vars, + 0, + subframe<<1, + &phy_vars_eNB->frame_parms, + phy_vars_eNB->do_precoding); + + // if S-subframe generate first slot only + if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL) { + do_OFDM_mod_symbol(&phy_vars_eNB->common_vars, + 0, + 1+(subframe<<1), + &phy_vars_eNB->frame_parms, + phy_vars_eNB->do_precoding); + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_OFDM_MODULATION,0); + + + /* + for (aa=0; aa<phy_vars_eNB->frame_parms.nb_antennas_tx; aa++) { + if (phy_vars_eNB->frame_parms.Ncp == EXTENDED) { + PHY_ofdm_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F], + dummy_tx_b, + phy_vars_eNB->frame_parms.ofdm_symbol_size, + 6, + phy_vars_eNB->frame_parms.nb_prefix_samples, + CYCLIC_PREFIX); + if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL) + PHY_ofdm_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F+slot_sizeF], + dummy_tx_b+(phy_vars_eNB->frame_parms.samples_per_tti>>1), + phy_vars_eNB->frame_parms.ofdm_symbol_size, + 6, + phy_vars_eNB->frame_parms.nb_prefix_samples, + CYCLIC_PREFIX); + } else { + normal_prefix_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F], + dummy_tx_b, + 7, + &(phy_vars_eNB->frame_parms)); + // if S-subframe generate first slot only + if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL) + normal_prefix_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F+slot_sizeF], + dummy_tx_b+(phy_vars_eNB->frame_parms.samples_per_tti>>1), + 7, + &(phy_vars_eNB->frame_parms)); + } + } */ + + for (aa=0; aa<phy_vars_eNB->frame_parms.nb_antennas_tx; aa++) { + // if S-subframe generate first slot only + if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_S) + len = phy_vars_eNB->frame_parms.samples_per_tti>>1; + else + len = phy_vars_eNB->frame_parms.samples_per_tti; + /* + for (i=0;i<len;i+=4) { + dummy_tx_b[i] = 0x100; + dummy_tx_b[i+1] = 0x01000000; + dummy_tx_b[i+2] = 0xff00; + dummy_tx_b[i+3] = 0xff000000; + }*/ + for (i=0; i<len; i++) { + tx_offset = (int)slot_offset+time_offset[aa]+i; + + + if (tx_offset<0) + tx_offset += LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; + + if (tx_offset>=(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti)) + tx_offset -= LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; + + /* ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[0] = ((short*)dummy_tx_b)[2*i]<<openair0_cfg[0].iq_txshift; + + ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[1] = ((short*)dummy_tx_b)[2*i+1]<<openair0_cfg[0].iq_txshift; */ + + ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[0] = ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[0]<<openair0_cfg[CC_id].iq_txshift; + + ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[1] = ((short*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset])[1]<<openair0_cfg[CC_id].iq_txshift; + } + // if S-subframe switch to RX in second subframe + if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_S) { + for (i=0; i<len; i++) { + phy_vars_eNB->common_vars.txdata[0][aa][tx_offset++] = 0x00010001; + } + } + + if ((((phy_vars_eNB->frame_parms.tdd_config==0) || + (phy_vars_eNB->frame_parms.tdd_config==1) || + (phy_vars_eNB->frame_parms.tdd_config==2) || + (phy_vars_eNB->frame_parms.tdd_config==6)) && + (subframe==0)) || (subframe==5)) { + // turn on tx switch N_TA_offset before + //LOG_D(HW,"subframe %d, time to switch to tx (N_TA_offset %d, slot_offset %d) \n",subframe,phy_vars_eNB->N_TA_offset,slot_offset); + for (i=0; i<phy_vars_eNB->N_TA_offset; i++) { + tx_offset = (int)slot_offset+time_offset[aa]+i-phy_vars_eNB->N_TA_offset; + if (tx_offset<0) + tx_offset += LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; + + if (tx_offset>=(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti)) + tx_offset -= LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; + + phy_vars_eNB->common_vars.txdata[0][aa][tx_offset] = 0x00000000; + } + } + } } - } } void tx_fh_if5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, proc->timestamp_tx&0xffffffff ); - if ((eNB->frame_parms.frame_type==FDD) || - ((eNB->frame_parms.frame_type==TDD) && - (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL))) - send_IF5(eNB, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_RRH_GW_DL); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, proc->timestamp_tx&0xffffffff ); + if ((eNB->frame_parms.frame_type==FDD) || + ((eNB->frame_parms.frame_type==TDD) && + (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL))) + send_IF5(eNB, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_RRH_GW_DL); } void tx_fh_if5_mobipass(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, proc->timestamp_tx&0xffffffff ); - if ((eNB->frame_parms.frame_type==FDD) || - ((eNB->frame_parms.frame_type==TDD) && - (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL))) - send_IF5(eNB, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_MOBIPASS); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, proc->timestamp_tx&0xffffffff ); + if ((eNB->frame_parms.frame_type==FDD) || + ((eNB->frame_parms.frame_type==TDD) && + (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL))) + send_IF5(eNB, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_MOBIPASS); } void tx_fh_if4p5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { - if ((eNB->frame_parms.frame_type==FDD) || - ((eNB->frame_parms.frame_type==TDD) && - (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL))) - send_IF4p5(eNB,proc->frame_tx,proc->subframe_tx, IF4p5_PDLFFT, 0); + if ((eNB->frame_parms.frame_type==FDD) || + ((eNB->frame_parms.frame_type==TDD) && + (subframe_select(&eNB->frame_parms,proc->subframe_tx) != SF_UL))) + send_IF4p5(eNB,proc->frame_tx,proc->subframe_tx, IF4p5_PDLFFT, 0); } void proc_tx_high0(PHY_VARS_eNB *eNB, - eNB_rxtx_proc_t *proc, - relaying_type_t r_type, - PHY_VARS_RN *rn) { - - int offset = proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB+offset, proc->frame_tx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB+offset, proc->subframe_tx ); - - phy_procedures_eNB_TX(eNB,proc,r_type,rn,1); - - /* we're done, let the next one proceed */ - if (pthread_mutex_lock(&sync_phy_proc.mutex_phy_proc_tx) != 0) { - LOG_E(PHY, "[SCHED][eNB] error locking PHY proc mutex for eNB TX proc\n"); - exit_fun("nothing to add"); - } - sync_phy_proc.phy_proc_CC_id++; - sync_phy_proc.phy_proc_CC_id %= MAX_NUM_CCs; - pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx); - if (pthread_mutex_unlock(&sync_phy_proc.mutex_phy_proc_tx) != 0) { - LOG_E(PHY, "[SCHED][eNB] error unlocking PHY proc mutex for eNB TX proc\n"); - exit_fun("nothing to add"); - } + eNB_rxtx_proc_t *proc, + relaying_type_t r_type, + PHY_VARS_RN *rn) { + + int offset = proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; + + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB+offset, proc->frame_tx ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB+offset, proc->subframe_tx ); + + phy_procedures_eNB_TX(eNB,proc,r_type,rn,1); + + /* we're done, let the next one proceed */ + if (pthread_mutex_lock(&sync_phy_proc.mutex_phy_proc_tx) != 0) { + LOG_E(PHY, "[SCHED][eNB] error locking PHY proc mutex for eNB TX proc\n"); + exit_fun("nothing to add"); + } + sync_phy_proc.phy_proc_CC_id++; + sync_phy_proc.phy_proc_CC_id %= MAX_NUM_CCs; + pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx); + if (pthread_mutex_unlock(&sync_phy_proc.mutex_phy_proc_tx) != 0) { + LOG_E(PHY, "[SCHED][eNB] error unlocking PHY proc mutex for eNB TX proc\n"); + exit_fun("nothing to add"); + } } void proc_tx_high(PHY_VARS_eNB *eNB, - eNB_rxtx_proc_t *proc, - relaying_type_t r_type, - PHY_VARS_RN *rn) { + eNB_rxtx_proc_t *proc, + relaying_type_t r_type, + PHY_VARS_RN *rn) { - // do PHY high - proc_tx_high0(eNB,proc,r_type,rn); + // do PHY high + proc_tx_high0(eNB,proc,r_type,rn); - // if TX fronthaul go ahead - if (eNB->tx_fh) eNB->tx_fh(eNB,proc); + // if TX fronthaul go ahead + if (eNB->tx_fh) eNB->tx_fh(eNB,proc); } void proc_tx_full(PHY_VARS_eNB *eNB, - eNB_rxtx_proc_t *proc, - relaying_type_t r_type, - PHY_VARS_RN *rn) { - - - // do PHY high - proc_tx_high0(eNB,proc,r_type,rn); - // do OFDM modulation - do_OFDM_mod_rt(proc->subframe_tx,eNB); - // if TX fronthaul go ahead - if (eNB->tx_fh) eNB->tx_fh(eNB,proc); - - /* - if (proc->frame_tx>1000) { - write_output("/tmp/txsig0.m","txs0", &eNB->common_vars.txdata[eNB->Mod_id][0][0], eNB->frame_parms.samples_per_tti*10,1,1); - write_output("/tmp/txsigF0.m","txsF0", &eNB->common_vars.txdataF[eNB->Mod_id][0][0],eNB->frame_parms.symbols_per_tti*eNB->frame_parms.ofdm_symbol_size*10,1,1); - write_output("/tmp/txsig1.m","txs1", &eNB->common_vars.txdata[eNB->Mod_id][1][0], eNB->frame_parms.samples_per_tti*10,1,1); - write_output("/tmp/txsigF1.m","txsF1", &eNB->common_vars.txdataF[eNB->Mod_id][1][0],eNB->frame_parms.symbols_per_tti*eNB->frame_parms.ofdm_symbol_size*10,1,1); - if (transmission_mode == 7) - write_output("/tmp/txsigF5.m","txsF5", &eNB->common_vars.txdataF[eNB->Mod_id][5][0],eNB->frame_parms.symbols_per_tti*eNB->frame_parms.ofdm_symbol_size*10,1,1); - exit_fun(""); - } - */ + eNB_rxtx_proc_t *proc, + relaying_type_t r_type, + PHY_VARS_RN *rn) { + + + // do PHY high + proc_tx_high0(eNB,proc,r_type,rn); + // do OFDM modulation + do_OFDM_mod_rt(proc->subframe_tx,eNB); + // if TX fronthaul go ahead + if (eNB->tx_fh) eNB->tx_fh(eNB,proc); + + /* + if (proc->frame_tx>1000) { + write_output("/tmp/txsig0.m","txs0", &eNB->common_vars.txdata[eNB->Mod_id][0][0], eNB->frame_parms.samples_per_tti*10,1,1); + write_output("/tmp/txsigF0.m","txsF0", &eNB->common_vars.txdataF[eNB->Mod_id][0][0],eNB->frame_parms.symbols_per_tti*eNB->frame_parms.ofdm_symbol_size*10,1,1); + write_output("/tmp/txsig1.m","txs1", &eNB->common_vars.txdata[eNB->Mod_id][1][0], eNB->frame_parms.samples_per_tti*10,1,1); + write_output("/tmp/txsigF1.m","txsF1", &eNB->common_vars.txdataF[eNB->Mod_id][1][0],eNB->frame_parms.symbols_per_tti*eNB->frame_parms.ofdm_symbol_size*10,1,1); + if (transmission_mode == 7) + write_output("/tmp/txsigF5.m","txsF5", &eNB->common_vars.txdataF[eNB->Mod_id][5][0],eNB->frame_parms.symbols_per_tti*eNB->frame_parms.ofdm_symbol_size*10,1,1); + exit_fun(""); + } + */ } void proc_tx_rru_if4p5(PHY_VARS_eNB *eNB, - eNB_rxtx_proc_t *proc, - relaying_type_t r_type, - PHY_VARS_RN *rn) { + eNB_rxtx_proc_t *proc, + relaying_type_t r_type, + PHY_VARS_RN *rn) { - uint32_t symbol_number=0; - uint32_t symbol_mask, symbol_mask_full; - uint16_t packet_type; + uint32_t symbol_number=0; + uint32_t symbol_mask, symbol_mask_full; + uint16_t packet_type; - int offset = proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; + int offset = proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB+offset, proc->frame_tx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB+offset, proc->subframe_tx ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB+offset, proc->frame_tx ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB+offset, proc->subframe_tx ); - /// **** recv_IF4 of txdataF from RCC **** /// - symbol_number = 0; - symbol_mask = 0; - symbol_mask_full = (1<<eNB->frame_parms.symbols_per_tti)-1; - + /// **** recv_IF4 of txdataF from RCC **** /// + symbol_number = 0; + symbol_mask = 0; + symbol_mask_full = (1<<eNB->frame_parms.symbols_per_tti)-1; - do { - recv_IF4p5(eNB, &proc->frame_tx, &proc->subframe_tx, &packet_type, &symbol_number); - symbol_mask = symbol_mask | (1<<symbol_number); - } while (symbol_mask != symbol_mask_full); - do_OFDM_mod_rt(proc->subframe_tx, eNB); + do { + recv_IF4p5(eNB, &proc->frame_tx, &proc->subframe_tx, &packet_type, &symbol_number); + symbol_mask = symbol_mask | (1<<symbol_number); + } while (symbol_mask != symbol_mask_full); + + do_OFDM_mod_rt(proc->subframe_tx, eNB); } void proc_tx_rru_if5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { - int offset = proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; + int offset = proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB+offset, proc->frame_tx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB+offset, proc->subframe_tx ); - /// **** recv_IF5 of txdata from BBU **** /// - recv_IF5(eNB, &proc->timestamp_tx, proc->subframe_tx, IF5_RRH_GW_DL); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB+offset, proc->frame_tx ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB+offset, proc->subframe_tx ); + /// **** recv_IF5 of txdata from BBU **** /// + recv_IF5(eNB, &proc->timestamp_tx, proc->subframe_tx, IF5_RRH_GW_DL); } int wait_CCs(eNB_rxtx_proc_t *proc) { - struct timespec wait; - - wait.tv_sec=0; - wait.tv_nsec=5000000L; - - if (pthread_mutex_timedlock(&sync_phy_proc.mutex_phy_proc_tx,&wait) != 0) { - LOG_E(PHY, "[SCHED][eNB] error locking PHY proc mutex for eNB TX\n"); - exit_fun("nothing to add"); - return(-1); - } - - // wait for our turn or oai_exit - while (sync_phy_proc.phy_proc_CC_id != proc->CC_id && !oai_exit) { - pthread_cond_wait(&sync_phy_proc.cond_phy_proc_tx, - &sync_phy_proc.mutex_phy_proc_tx); - } - - if (pthread_mutex_unlock(&sync_phy_proc.mutex_phy_proc_tx) != 0) { - LOG_E(PHY, "[SCHED][eNB] error unlocking PHY proc mutex for eNB TX\n"); - exit_fun("nothing to add"); - return(-1); - } - return(0); + struct timespec wait; + + wait.tv_sec=0; + wait.tv_nsec=5000000L; + + if (pthread_mutex_timedlock(&sync_phy_proc.mutex_phy_proc_tx,&wait) != 0) { + LOG_E(PHY, "[SCHED][eNB] error locking PHY proc mutex for eNB TX\n"); + exit_fun("nothing to add"); + return(-1); + } + + // wait for our turn or oai_exit + while (sync_phy_proc.phy_proc_CC_id != proc->CC_id && !oai_exit) { + pthread_cond_wait(&sync_phy_proc.cond_phy_proc_tx, + &sync_phy_proc.mutex_phy_proc_tx); + } + + if (pthread_mutex_unlock(&sync_phy_proc.mutex_phy_proc_tx) != 0) { + LOG_E(PHY, "[SCHED][eNB] error unlocking PHY proc mutex for eNB TX\n"); + exit_fun("nothing to add"); + return(-1); + } + return(0); } static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_name) { - start_meas(&softmodem_stats_rxtx_sf); - - // **************************************** - // Common RX procedures subframe n - - if ((eNB->do_prach)&&((eNB->node_function != NGFI_RCC_IF4p5))) - eNB->do_prach(eNB,proc->frame_rx,proc->subframe_rx); - phy_procedures_eNB_common_RX(eNB,proc); - - // UE-specific RX processing for subframe n - if (eNB->proc_uespec_rx) eNB->proc_uespec_rx(eNB, proc, no_relay ); - - // ***************************************** - // 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); - - if (eNB->proc_tx) eNB->proc_tx(eNB, proc, no_relay, NULL ); - - if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) return(-1); - - stop_meas( &softmodem_stats_rxtx_sf ); - - return(0); + start_meas(&softmodem_stats_rxtx_sf); + + // **************************************** + // Common RX procedures subframe n + + if ((eNB->do_prach)&&((eNB->node_function != NGFI_RCC_IF4p5))) + eNB->do_prach(eNB,proc->frame_rx,proc->subframe_rx); + phy_procedures_eNB_common_RX(eNB,proc); + + // UE-specific RX processing for subframe n + if (eNB->proc_uespec_rx) eNB->proc_uespec_rx(eNB, proc, no_relay ); + + // ***************************************** + // 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); + + if (eNB->proc_tx) eNB->proc_tx(eNB, proc, no_relay, NULL ); + + if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) return(-1); + + stop_meas( &softmodem_stats_rxtx_sf ); + + return(0); } /*! @@ -597,61 +546,62 @@ 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; + static int eNB_thread_rxtx_status; - eNB_rxtx_proc_t *proc = (eNB_rxtx_proc_t*)param; - PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id]; + eNB_rxtx_proc_t *proc = (eNB_rxtx_proc_t*)param; + PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id]; - char thread_name[100]; + char thread_name[100]; - // set default return value - eNB_thread_rxtx_status = 0; + // set default return value + eNB_thread_rxtx_status = 0; - sprintf(thread_name,"RXn_TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); - thread_top_init(thread_name,1,850000L,1000000L,2000000L); + 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) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); + 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; - 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 ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 1 ); - - - if (oai_exit) break; - if (eNB->CC_id==0) - if (rxtx(eNB,proc,thread_name) < 0) break; + if (oai_exit) break; - } // while !oai_exit + if (eNB->CC_id==0) + if (rxtx(eNB,proc,thread_name) < 0) break; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); + } // while !oai_exit + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); - printf( "Exiting eNB thread RXn_TXnp4\n"); + printf( "Exiting eNB thread RXn_TXnp4\n"); - eNB_thread_rxtx_status = 0; - return &eNB_thread_rxtx_status; + eNB_thread_rxtx_status = 0; + return &eNB_thread_rxtx_status; } #if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME) /* Wait for eNB application initialization to be complete (eNB registration to MME) */ static void wait_system_ready (char *message, volatile int *start_flag) { - - static char *indicator[] = {". ", ".. ", "... ", ".... ", ".....", - " ....", " ...", " ..", " .", " "}; - int i = 0; - - while ((!oai_exit) && (*start_flag == 0)) { - LOG_N(EMU, message, indicator[i]); - fflush(stdout); - i = (i + 1) % (sizeof(indicator) / sizeof(indicator[0])); - usleep(200000); - } - - LOG_D(EMU,"\n"); + + static char *indicator[] = {". ", ".. ", "... ", ".... ", ".....", + " ....", " ...", " ..", " .", " " + }; + int i = 0; + + while ((!oai_exit) && (*start_flag == 0)) { + LOG_N(EMU, message, indicator[i]); + fflush(stdout); + i = (i + 1) % (sizeof(indicator) / sizeof(indicator[0])); + usleep(200000); + } + + LOG_D(EMU,"\n"); } #endif @@ -659,187 +609,182 @@ static void wait_system_ready (char *message, volatile int *start_flag) { // asynchronous UL with IF5 (RCC,RAU,eNodeB_BBU) void fh_if5_asynch_UL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { - eNB_proc_t *proc = &eNB->proc; - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - - recv_IF5(eNB, &proc->timestamp_rx, *subframe, IF5_MOBIPASS); - - int offset_mobipass = 40120; - pthread_mutex_lock(&proc->mutex_asynch_rxtx); - proc->subframe_rx = ((proc->timestamp_rx-offset_mobipass)/fp->samples_per_tti)%10; - proc->frame_rx = ((proc->timestamp_rx-offset_mobipass)/(fp->samples_per_tti*10))&1023; - - if (proc->first_rx == 1) { - proc->first_rx =2; - *subframe = proc->subframe_rx; - *frame = proc->frame_rx; - LOG_E(PHY,"[Mobipass]timestamp_rx:%llu, frame_rx %d, subframe: %d\n",proc->timestamp_rx,proc->frame_rx,proc->subframe_rx); - } - else { - if (proc->subframe_rx != *subframe) { - proc->first_rx++; - LOG_E(PHY,"[Mobipass]timestamp:%llu, subframe_rx %d is not what we expect %d, first_rx:%d\n",proc->timestamp_rx, proc->subframe_rx,*subframe, proc->first_rx); - //exit_fun("Exiting"); - } - if (proc->frame_rx != *frame) { - proc->first_rx++; - LOG_E(PHY,"[Mobipass]timestamp:%llu, frame_rx %d is not what we expect %d, first_rx:%d\n",proc->timestamp_rx,proc->frame_rx,*frame, proc->first_rx); - // exit_fun("Exiting"); + eNB_proc_t *proc = &eNB->proc; + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + + recv_IF5(eNB, &proc->timestamp_rx, *subframe, IF5_MOBIPASS); + + int offset_mobipass = 40120; + pthread_mutex_lock(&proc->mutex_asynch_rxtx); + proc->subframe_rx = ((proc->timestamp_rx-offset_mobipass)/fp->samples_per_tti)%10; + proc->frame_rx = ((proc->timestamp_rx-offset_mobipass)/(fp->samples_per_tti*10))&1023; + + if (proc->first_rx == 1) { + proc->first_rx =2; + *subframe = proc->subframe_rx; + *frame = proc->frame_rx; + LOG_E(PHY,"[Mobipass]timestamp_rx:%llu, frame_rx %d, subframe: %d\n",proc->timestamp_rx,proc->frame_rx,proc->subframe_rx); + } else { + if (proc->subframe_rx != *subframe) { + proc->first_rx++; + LOG_E(PHY,"[Mobipass]timestamp:%llu, subframe_rx %d is not what we expect %d, first_rx:%d\n",proc->timestamp_rx, proc->subframe_rx,*subframe, proc->first_rx); + //exit_fun("Exiting"); + } + if (proc->frame_rx != *frame) { + proc->first_rx++; + LOG_E(PHY,"[Mobipass]timestamp:%llu, frame_rx %d is not what we expect %d, first_rx:%d\n",proc->timestamp_rx,proc->frame_rx,*frame, proc->first_rx); + // exit_fun("Exiting"); + } + // temporary solution + *subframe = proc->subframe_rx; + *frame = proc->frame_rx; } - // temporary solution - *subframe = proc->subframe_rx; - *frame = proc->frame_rx; - } - pthread_mutex_unlock(&proc->mutex_asynch_rxtx); + pthread_mutex_unlock(&proc->mutex_asynch_rxtx); -} // eNodeB_3GPP_BBU +} // eNodeB_3GPP_BBU // asynchronous UL with IF4p5 (RCC,RAU,eNodeB_BBU) void fh_if4p5_asynch_UL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - eNB_proc_t *proc = &eNB->proc; + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + eNB_proc_t *proc = &eNB->proc; - uint16_t packet_type; - uint32_t symbol_number,symbol_mask,symbol_mask_full,prach_rx; + uint16_t packet_type; + uint32_t symbol_number,symbol_mask,symbol_mask_full,prach_rx; - symbol_number = 0; - symbol_mask = 0; - symbol_mask_full = (1<<fp->symbols_per_tti)-1; - prach_rx = 0; + symbol_number = 0; + symbol_mask = 0; + symbol_mask_full = (1<<fp->symbols_per_tti)-1; + prach_rx = 0; + + do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! + recv_IF4p5(eNB, &proc->frame_rx, &proc->subframe_rx, &packet_type, &symbol_number); + if (proc->first_rx != 0) { + *frame = proc->frame_rx; + *subframe = proc->subframe_rx; + proc->first_rx--; + } else { + if (proc->frame_rx != *frame) { + LOG_E(PHY,"fh_if4p5_asynch_UL: frame_rx %d is not what we expect %d\n",proc->frame_rx,*frame); + exit_fun("Exiting"); + } + if (proc->subframe_rx != *subframe) { + LOG_E(PHY,"fh_if4p5_asynch_UL: subframe_rx %d is not what we expect %d\n",proc->subframe_rx,*subframe); + exit_fun("Exiting"); + } + } + if (packet_type == IF4p5_PULFFT) { + symbol_mask = symbol_mask | (1<<symbol_number); + prach_rx = (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)>0) ? 1 : 0; + } else if (packet_type == IF4p5_PRACH) { + prach_rx = 0; + } + } while( (symbol_mask != symbol_mask_full) || (prach_rx == 1)); - do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! - recv_IF4p5(eNB, &proc->frame_rx, &proc->subframe_rx, &packet_type, &symbol_number); - if (proc->first_rx != 0) { - *frame = proc->frame_rx; - *subframe = proc->subframe_rx; - proc->first_rx--; - } - else { - if (proc->frame_rx != *frame) { - LOG_E(PHY,"fh_if4p5_asynch_UL: frame_rx %d is not what we expect %d\n",proc->frame_rx,*frame); - exit_fun("Exiting"); - } - if (proc->subframe_rx != *subframe) { - LOG_E(PHY,"fh_if4p5_asynch_UL: subframe_rx %d is not what we expect %d\n",proc->subframe_rx,*subframe); - exit_fun("Exiting"); - } - } - if (packet_type == IF4p5_PULFFT) { - symbol_mask = symbol_mask | (1<<symbol_number); - prach_rx = (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)>0) ? 1 : 0; - } else if (packet_type == IF4p5_PRACH) { - prach_rx = 0; - } - } while( (symbol_mask != symbol_mask_full) || (prach_rx == 1)); - -} +} void fh_if5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - eNB_proc_t *proc = &eNB->proc; - int subframe_tx,frame_tx; - openair0_timestamp timestamp_tx; - - recv_IF5(eNB, ×tamp_tx, *subframe, IF5_RRH_GW_DL); - //printf("Received subframe %d (TS %llu) from RCC\n",subframe_tx,timestamp_tx); - - subframe_tx = (timestamp_tx/fp->samples_per_tti)%10; - frame_tx = (timestamp_tx/(fp->samples_per_tti*10))&1023; - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB, frame_tx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB, subframe_tx ); - - if (proc->first_tx != 0) { - *subframe = subframe_tx; - *frame = frame_tx; - proc->first_tx = 0; - } - else { - if (subframe_tx != *subframe) { - LOG_E(PHY,"fh_if5_asynch_DL: subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe); - exit_fun("Exiting"); - } - if (frame_tx != *frame) { - LOG_E(PHY,"fh_if5_asynch_DL: frame_tx %d is not what we expect %d\n",frame_tx,*frame); - exit_fun("Exiting"); + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + eNB_proc_t *proc = &eNB->proc; + int subframe_tx,frame_tx; + openair0_timestamp timestamp_tx; + + recv_IF5(eNB, ×tamp_tx, *subframe, IF5_RRH_GW_DL); + //printf("Received subframe %d (TS %llu) from RCC\n",subframe_tx,timestamp_tx); + + subframe_tx = (timestamp_tx/fp->samples_per_tti)%10; + frame_tx = (timestamp_tx/(fp->samples_per_tti*10))&1023; + + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB, frame_tx ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB, subframe_tx ); + + if (proc->first_tx != 0) { + *subframe = subframe_tx; + *frame = frame_tx; + proc->first_tx = 0; + } else { + if (subframe_tx != *subframe) { + LOG_E(PHY,"fh_if5_asynch_DL: subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe); + exit_fun("Exiting"); + } + if (frame_tx != *frame) { + LOG_E(PHY,"fh_if5_asynch_DL: frame_tx %d is not what we expect %d\n",frame_tx,*frame); + exit_fun("Exiting"); + } } - } } void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - eNB_proc_t *proc = &eNB->proc; + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + eNB_proc_t *proc = &eNB->proc; - uint16_t packet_type; - uint32_t symbol_number,symbol_mask_full; - int subframe_tx,frame_tx; + uint16_t packet_type; + uint32_t symbol_number,symbol_mask_full; + int subframe_tx,frame_tx; - symbol_number = 0; + symbol_number = 0; - LOG_D(PHY,"fh_asynch_DL_IF4p5: in, frame %d, subframe %d\n",*frame,*subframe); + LOG_D(PHY,"fh_asynch_DL_IF4p5: in, frame %d, subframe %d\n",*frame,*subframe); - // correct for TDD - if (fp->frame_type == TDD) { - while (subframe_select(fp,*subframe) == SF_UL) { - *subframe=*subframe+1; - if (*subframe==10) { - *subframe=0; - *frame=*frame+1; - } + // correct for TDD + if (fp->frame_type == TDD) { + while (subframe_select(fp,*subframe) == SF_UL) { + *subframe=*subframe+1; + if (*subframe==10) { + *subframe=0; + *frame=*frame+1; + } + } } - } - LOG_D(PHY,"fh_asynch_DL_IF4p5: after TDD correction, frame %d, subframe %d\n",*frame,*subframe); - - symbol_mask_full = ((subframe_select(fp,*subframe) == SF_S) ? (1<<fp->dl_symbols_in_S_subframe) : (1<<fp->symbols_per_tti))-1; - do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! - recv_IF4p5(eNB, &frame_tx, &subframe_tx, &packet_type, &symbol_number); - if (proc->first_tx != 0) { - *frame = frame_tx; - *subframe = subframe_tx; - proc->first_tx = 0; - proc->frame_offset = frame_tx - proc->frame_tx; - symbol_mask_full = ((subframe_select(fp,*subframe) == SF_S) ? (1<<fp->dl_symbols_in_S_subframe) : (1<<fp->symbols_per_tti))-1; + LOG_D(PHY,"fh_asynch_DL_IF4p5: after TDD correction, frame %d, subframe %d\n",*frame,*subframe); + + symbol_mask_full = ((subframe_select(fp,*subframe) == SF_S) ? (1<<fp->dl_symbols_in_S_subframe) : (1<<fp->symbols_per_tti))-1; + do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! + recv_IF4p5(eNB, &frame_tx, &subframe_tx, &packet_type, &symbol_number); + if (proc->first_tx != 0) { + *frame = frame_tx; + *subframe = subframe_tx; + proc->first_tx = 0; + proc->frame_offset = frame_tx - proc->frame_tx; + symbol_mask_full = ((subframe_select(fp,*subframe) == SF_S) ? (1<<fp->dl_symbols_in_S_subframe) : (1<<fp->symbols_per_tti))-1; + + } else { + if (frame_tx != *frame) { + LOG_E(PHY,"fh_if4p5_asynch_DL: frame_tx %d is not what we expect %d\n",frame_tx,*frame); + exit_fun("Exiting"); + } + if (subframe_tx != *subframe) { + LOG_E(PHY,"fh_if4p5_asynch_DL: (frame %d) subframe_tx %d is not what we expect %d\n",frame_tx,subframe_tx,*subframe); + //*subframe = subframe_tx; + exit_fun("Exiting"); + } + } + if (packet_type == IF4p5_PDLFFT) { + proc->symbol_mask[subframe_tx] =proc->symbol_mask[subframe_tx] | (1<<symbol_number); + } else { + LOG_E(PHY,"Illegal IF4p5 packet type (should only be IF4p5_PDLFFT%d\n",packet_type); + exit_fun("Exiting"); + } + } while (proc->symbol_mask[*subframe] != symbol_mask_full); - } - else { - if (frame_tx != *frame) { - LOG_E(PHY,"fh_if4p5_asynch_DL: frame_tx %d is not what we expect %d\n",frame_tx,*frame); - exit_fun("Exiting"); - } - if (subframe_tx != *subframe) { - LOG_E(PHY,"fh_if4p5_asynch_DL: (frame %d) subframe_tx %d is not what we expect %d\n",frame_tx,subframe_tx,*subframe); - //*subframe = subframe_tx; - exit_fun("Exiting"); - } - } - if (packet_type == IF4p5_PDLFFT) { - proc->symbol_mask[subframe_tx] =proc->symbol_mask[subframe_tx] | (1<<symbol_number); - } - else { - LOG_E(PHY,"Illegal IF4p5 packet type (should only be IF4p5_PDLFFT%d\n",packet_type); - exit_fun("Exiting"); - } - } while (proc->symbol_mask[*subframe] != symbol_mask_full); + *frame = frame_tx; - *frame = frame_tx; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB, frame_tx ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB, subframe_tx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB, frame_tx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB, subframe_tx ); + // intialize this to zero after we're done with the subframe + proc->symbol_mask[*subframe] = 0; - // intialize this to zero after we're done with the subframe - proc->symbol_mask[*subframe] = 0; - - do_OFDM_mod_rt(*subframe, eNB); -} + do_OFDM_mod_rt(*subframe, eNB); +} /*! * \brief The Asynchronous RX/TX FH thread of RAU/RCC/eNB/RRU. @@ -849,48 +794,48 @@ void fh_if4p5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) { */ static void* eNB_thread_asynch_rxtx( void* param ) { - static int eNB_thread_asynch_rxtx_status; + static int eNB_thread_asynch_rxtx_status; - eNB_proc_t *proc = (eNB_proc_t*)param; - PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id]; + eNB_proc_t *proc = (eNB_proc_t*)param; + PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id]; - int subframe=0, frame=0; + int subframe=0, frame=0; - thread_top_init("thread_asynch",1,870000L,1000000L,1000000L); + thread_top_init("thread_asynch",1,870000L,1000000L,1000000L); - // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe + // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe - wait_sync("thread_asynch"); + wait_sync("thread_asynch"); - // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe - printf( "waiting for devices (eNB_thread_asynch_rx)\n"); + // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe + printf( "waiting for devices (eNB_thread_asynch_rx)\n"); - wait_on_condition(&proc->mutex_asynch_rxtx,&proc->cond_asynch_rxtx,&proc->instance_cnt_asynch_rxtx,"thread_asynch"); + wait_on_condition(&proc->mutex_asynch_rxtx,&proc->cond_asynch_rxtx,&proc->instance_cnt_asynch_rxtx,"thread_asynch"); - printf( "devices ok (eNB_thread_asynch_rx)\n"); + printf( "devices ok (eNB_thread_asynch_rx)\n"); - while (!oai_exit) { - - if (oai_exit) break; + while (!oai_exit) { - if (subframe==9) { - subframe=0; - frame++; - frame&=1023; - } else { - subframe++; - } + if (oai_exit) break; - if (eNB->fh_asynch) eNB->fh_asynch(eNB,&frame,&subframe); - else AssertFatal(1==0, "Unknown eNB->node_function %d",eNB->node_function); - - } + if (subframe==9) { + subframe=0; + frame++; + frame&=1023; + } else { + subframe++; + } + + if (eNB->fh_asynch) eNB->fh_asynch(eNB,&frame,&subframe); + else AssertFatal(1==0, "Unknown eNB->node_function %d",eNB->node_function); - eNB_thread_asynch_rxtx_status=0; - return(&eNB_thread_asynch_rxtx_status); + } + + eNB_thread_asynch_rxtx_status=0; + return(&eNB_thread_asynch_rxtx_status); } @@ -899,365 +844,364 @@ static void* eNB_thread_asynch_rxtx( void* param ) { void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) { - eNB_proc_t *proc = &eNB->proc; - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - void *rxp[fp->nb_antennas_rx],*txp[fp->nb_antennas_tx]; - unsigned int rxs,txs; - int i; - int tx_sfoffset = (eNB->single_thread_flag == 1) ? 3 : 2; - openair0_timestamp ts,old_ts; - - if (proc->first_rx==0) { - - // Transmit TX buffer based on timestamp from RX - // printf("trx_write -> USRP TS %llu (sf %d)\n", (proc->timestamp_rx+(3*fp->samples_per_tti)),(proc->subframe_rx+2)%10); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_rx+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance)&0xffffffff ); - // prepare tx buffer pointers - - lte_subframe_t SF_type = subframe_select(fp,(proc->subframe_rx+tx_sfoffset)%10); - lte_subframe_t prevSF_type = subframe_select(fp,(proc->subframe_rx+tx_sfoffset+9)%10); - lte_subframe_t nextSF_type = subframe_select(fp,(proc->subframe_rx+tx_sfoffset+1)%10); - if ((SF_type == SF_DL) || - (SF_type == SF_S)) { - - for (i=0; i<fp->nb_antennas_tx; i++) - txp[i] = (void*)&eNB->common_vars.txdata[0][i][((proc->subframe_rx+tx_sfoffset)%10)*fp->samples_per_tti]; - - int siglen=fp->samples_per_tti,flags=1; - - if (SF_type == SF_S) { - siglen = fp->dl_symbols_in_S_subframe*(fp->ofdm_symbol_size+fp->nb_prefix_samples0); - flags=3; // end of burst - } - if ((fp->frame_type == TDD) && - (SF_type == SF_DL)&& - (prevSF_type == SF_UL) && - (nextSF_type == SF_DL)) - flags = 2; // start of burst - - if ((fp->frame_type == TDD) && - (SF_type == SF_DL)&& - (prevSF_type == SF_UL) && - (nextSF_type == SF_UL)) - flags = 4; // start of burst and end of burst (only one DL SF between two UL) - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_WRITE_FLAGS,flags); - txs = eNB->rfdevice.trx_write_func(&eNB->rfdevice, - proc->timestamp_rx+eNB->ts_offset+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance, - txp, - siglen, - fp->nb_antennas_tx, - flags); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); - - - - if (txs != siglen) { - LOG_E(PHY,"TX : Timeout (sent %d/%d)\n",txs, fp->samples_per_tti); - exit_fun( "problem transmitting samples" ); - } - } - } - - for (i=0; i<fp->nb_antennas_rx; i++) - rxp[i] = (void*)&eNB->common_vars.rxdata[0][i][*subframe*fp->samples_per_tti]; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); - - old_ts = proc->timestamp_rx; - - rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, - &ts, - rxp, - fp->samples_per_tti, - fp->nb_antennas_rx); - - proc->timestamp_rx = ts-eNB->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); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); - - if (proc->first_rx == 1) { - eNB->ts_offset = proc->timestamp_rx; - proc->timestamp_rx=0; - } - else { - - if (proc->timestamp_rx - old_ts != fp->samples_per_tti) { - LOG_I(PHY,"rx_rf: rfdevice timing drift of %d samples\n",proc->timestamp_rx - old_ts - fp->samples_per_tti); - eNB->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_tti); - proc->timestamp_rx = ts-eNB->ts_offset; + eNB_proc_t *proc = &eNB->proc; + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + void *rxp[fp->nb_antennas_rx],*txp[fp->nb_antennas_tx]; + unsigned int rxs,txs; + int i; + int tx_sfoffset = (eNB->single_thread_flag == 1) ? 3 : 2; + openair0_timestamp ts,old_ts; + + if (proc->first_rx==0) { + + // Transmit TX buffer based on timestamp from RX + // printf("trx_write -> USRP TS %llu (sf %d)\n", (proc->timestamp_rx+(3*fp->samples_per_tti)),(proc->subframe_rx+2)%10); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_rx+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance)&0xffffffff ); + // prepare tx buffer pointers + + lte_subframe_t SF_type = subframe_select(fp,(proc->subframe_rx+tx_sfoffset)%10); + lte_subframe_t prevSF_type = subframe_select(fp,(proc->subframe_rx+tx_sfoffset+9)%10); + lte_subframe_t nextSF_type = subframe_select(fp,(proc->subframe_rx+tx_sfoffset+1)%10); + if ((SF_type == SF_DL) || + (SF_type == SF_S)) { + + for (i=0; i<fp->nb_antennas_tx; i++) + txp[i] = (void*)&eNB->common_vars.txdata[0][i][((proc->subframe_rx+tx_sfoffset)%10)*fp->samples_per_tti]; + + int siglen=fp->samples_per_tti,flags=1; + + if (SF_type == SF_S) { + siglen = fp->dl_symbols_in_S_subframe*(fp->ofdm_symbol_size+fp->nb_prefix_samples0); + flags=3; // end of burst + } + if ((fp->frame_type == TDD) && + (SF_type == SF_DL)&& + (prevSF_type == SF_UL) && + (nextSF_type == SF_DL)) + flags = 2; // start of burst + + if ((fp->frame_type == TDD) && + (SF_type == SF_DL)&& + (prevSF_type == SF_UL) && + (nextSF_type == SF_UL)) + flags = 4; // start of burst and end of burst (only one DL SF between two UL) + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_WRITE_FLAGS,flags); + txs = eNB->rfdevice.trx_write_func(&eNB->rfdevice, + proc->timestamp_rx+eNB->ts_offset+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance, + txp, + siglen, + fp->nb_antennas_tx, + flags); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); + + + + if (txs != siglen) { + LOG_E(PHY,"TX : Timeout (sent %d/%d)\n",txs, fp->samples_per_tti); + exit_fun( "problem transmitting samples" ); + } + } } - } - proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; - proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; - proc->frame_rx = (proc->frame_rx+proc->frame_offset)&1023; - proc->frame_tx = proc->frame_rx; - if (proc->subframe_rx > 5) proc->frame_tx=(proc->frame_tx+1)&1023; - // synchronize first reception to frame 0 subframe 0 - - proc->timestamp_tx = proc->timestamp_rx+(4*fp->samples_per_tti); - // printf("trx_read <- USRP TS %lu (offset %d sf %d, f %d, first_rx %d)\n", proc->timestamp_rx,eNB->ts_offset,proc->subframe_rx,proc->frame_rx,proc->first_rx); - - if (proc->first_rx == 0) { - if (proc->subframe_rx != *subframe){ - LOG_E(PHY,"rx_rf: Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->timestamp_rx,proc->subframe_rx,*subframe); - exit_fun("Exiting"); + + for (i=0; i<fp->nb_antennas_rx; i++) + rxp[i] = (void*)&eNB->common_vars.rxdata[0][i][*subframe*fp->samples_per_tti]; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); + + old_ts = proc->timestamp_rx; + + rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, + &ts, + rxp, + fp->samples_per_tti, + fp->nb_antennas_rx); + + proc->timestamp_rx = ts-eNB->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); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); + + if (proc->first_rx == 1) { + eNB->ts_offset = proc->timestamp_rx; + proc->timestamp_rx=0; + } else { + + if (proc->timestamp_rx - old_ts != fp->samples_per_tti) { + LOG_I(PHY,"rx_rf: rfdevice timing drift of %d samples\n",proc->timestamp_rx - old_ts - fp->samples_per_tti); + eNB->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_tti); + proc->timestamp_rx = ts-eNB->ts_offset; + } } - int f2 = (*frame+proc->frame_offset)&1023; - if (proc->frame_rx != f2) { - LOG_E(PHY,"rx_rf: Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d, frame_offset %d, f2 %d)\n",proc->timestamp_rx,proc->frame_rx,*frame,proc->frame_offset,f2); - exit_fun("Exiting"); + proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; + proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; + proc->frame_rx = (proc->frame_rx+proc->frame_offset)&1023; + proc->frame_tx = proc->frame_rx; + if (proc->subframe_rx > 5) proc->frame_tx=(proc->frame_tx+1)&1023; + // synchronize first reception to frame 0 subframe 0 + + proc->timestamp_tx = proc->timestamp_rx+(4*fp->samples_per_tti); + // printf("trx_read <- USRP TS %lu (offset %d sf %d, f %d, first_rx %d)\n", proc->timestamp_rx,eNB->ts_offset,proc->subframe_rx,proc->frame_rx,proc->first_rx); + + if (proc->first_rx == 0) { + if (proc->subframe_rx != *subframe) { + LOG_E(PHY,"rx_rf: Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->timestamp_rx,proc->subframe_rx,*subframe); + exit_fun("Exiting"); + } + int f2 = (*frame+proc->frame_offset)&1023; + if (proc->frame_rx != f2) { + LOG_E(PHY,"rx_rf: Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d, frame_offset %d, f2 %d)\n",proc->timestamp_rx,proc->frame_rx,*frame,proc->frame_offset,f2); + exit_fun("Exiting"); + } + } else { + proc->first_rx--; + *frame = proc->frame_rx; + *subframe = proc->subframe_rx; } - } else { - proc->first_rx--; - *frame = proc->frame_rx; - *subframe = proc->subframe_rx; - } - - //printf("timestamp_rx %lu, frame %d(%d), subframe %d(%d)\n",proc->timestamp_rx,proc->frame_rx,frame,proc->subframe_rx,subframe); - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); - - if (rxs != fp->samples_per_tti) - exit_fun( "problem receiving samples" ); - - - + + //printf("timestamp_rx %lu, frame %d(%d), subframe %d(%d)\n",proc->timestamp_rx,proc->frame_rx,frame,proc->subframe_rx,subframe); + + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); + + if (rxs != fp->samples_per_tti) + exit_fun( "problem receiving samples" ); + + + } void rx_fh_if5(PHY_VARS_eNB *eNB,int *frame, int *subframe) { - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - eNB_proc_t *proc = &eNB->proc; + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + eNB_proc_t *proc = &eNB->proc; - recv_IF5(eNB, &proc->timestamp_rx, *subframe, IF5_RRH_GW_UL); + recv_IF5(eNB, &proc->timestamp_rx, *subframe, IF5_RRH_GW_UL); - proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; - proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; - - if (proc->first_rx == 0) { - if (proc->subframe_rx != *subframe){ - LOG_E(PHY,"rx_fh_if5: Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,*subframe); - exit_fun("Exiting"); - } - - if (proc->frame_rx != *frame) { - LOG_E(PHY,"rx_fh_if5: Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->frame_rx,*frame); - exit_fun("Exiting"); + proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; + proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; + + if (proc->first_rx == 0) { + if (proc->subframe_rx != *subframe) { + LOG_E(PHY,"rx_fh_if5: Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,*subframe); + exit_fun("Exiting"); + } + + if (proc->frame_rx != *frame) { + LOG_E(PHY,"rx_fh_if5: Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->frame_rx,*frame); + exit_fun("Exiting"); + } + } else { + proc->first_rx--; + *frame = proc->frame_rx; + *subframe = proc->subframe_rx; } - } else { - proc->first_rx--; - *frame = proc->frame_rx; - *subframe = proc->subframe_rx; - } - proc->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); + proc->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); + + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); } void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) { - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - eNB_proc_t *proc = &eNB->proc; - int f,sf; + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + eNB_proc_t *proc = &eNB->proc; + int f,sf; - uint16_t packet_type; - uint32_t symbol_number=0; - uint32_t symbol_mask_full; + uint16_t packet_type; + uint32_t symbol_number=0; + uint32_t symbol_mask_full; - if ((fp->frame_type == TDD) && (subframe_select(fp,*subframe)==SF_S)) - symbol_mask_full = (1<<fp->ul_symbols_in_S_subframe)-1; - else - symbol_mask_full = (1<<fp->symbols_per_tti)-1; + if ((fp->frame_type == TDD) && (subframe_select(fp,*subframe)==SF_S)) + symbol_mask_full = (1<<fp->ul_symbols_in_S_subframe)-1; + else + symbol_mask_full = (1<<fp->symbols_per_tti)-1; + + if (eNB->CC_id==1) LOG_I(PHY,"rx_fh_if4p5: frame %d, subframe %d\n",*frame,*subframe); + do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! + recv_IF4p5(eNB, &f, &sf, &packet_type, &symbol_number); + + //proc->frame_rx = (proc->frame_rx + proc->frame_offset)&1023; + if (packet_type == IF4p5_PULFFT) { + LOG_D(PHY,"rx_fh_if4p5: frame %d, subframe %d, PULFFT symbol %d\n",f,sf,symbol_number); + + proc->symbol_mask[sf] = proc->symbol_mask[sf] | (1<<symbol_number); + } else if (packet_type == IF4p5_PULTICK) { + + if ((proc->first_rx==0) && (f!=*frame)) + LOG_E(PHY,"rx_fh_if4p5: PULTICK received frame %d != expected %d\n",f,*frame); + if ((proc->first_rx==0) && (sf!=*subframe)) + LOG_E(PHY,"rx_fh_if4p5: PULTICK received subframe %d != expected %d (first_rx %d)\n",sf,*subframe,proc->first_rx); + break; + } else if (packet_type == IF4p5_PRACH) { + LOG_D(PHY,"rx_fh:if4p5: frame %d, subframe %d, PRACH\n",f,sf); + // wakeup prach processing + if (eNB->do_prach) eNB->do_prach(eNB,f,sf); + } - if (eNB->CC_id==1) LOG_I(PHY,"rx_fh_if4p5: frame %d, subframe %d\n",*frame,*subframe); - do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! - recv_IF4p5(eNB, &f, &sf, &packet_type, &symbol_number); - - //proc->frame_rx = (proc->frame_rx + proc->frame_offset)&1023; - if (packet_type == IF4p5_PULFFT) { - LOG_D(PHY,"rx_fh_if4p5: frame %d, subframe %d, PULFFT symbol %d\n",f,sf,symbol_number); - - proc->symbol_mask[sf] = proc->symbol_mask[sf] | (1<<symbol_number); - } else if (packet_type == IF4p5_PULTICK) { - - if ((proc->first_rx==0) && (f!=*frame)) - LOG_E(PHY,"rx_fh_if4p5: PULTICK received frame %d != expected %d\n",f,*frame); - if ((proc->first_rx==0) && (sf!=*subframe)) - LOG_E(PHY,"rx_fh_if4p5: PULTICK received subframe %d != expected %d (first_rx %d)\n",sf,*subframe,proc->first_rx); - break; - } else if (packet_type == IF4p5_PRACH) { - LOG_D(PHY,"rx_fh:if4p5: frame %d, subframe %d, PRACH\n",f,sf); - // wakeup prach processing - if (eNB->do_prach) eNB->do_prach(eNB,f,sf); - } + if (eNB->CC_id==1) LOG_I(PHY,"rx_fh_if4p5: symbol_mask[%d] %x\n",*subframe,proc->symbol_mask[*subframe]); - if (eNB->CC_id==1) LOG_I(PHY,"rx_fh_if4p5: symbol_mask[%d] %x\n",*subframe,proc->symbol_mask[*subframe]); + } while(proc->symbol_mask[*subframe] != symbol_mask_full); - } while(proc->symbol_mask[*subframe] != symbol_mask_full); + proc->subframe_rx = sf; + proc->frame_rx = f; - proc->subframe_rx = sf; - proc->frame_rx = f; + proc->symbol_mask[*subframe] = 0; + proc->symbol_mask[(9+*subframe)%10]= 0; // to handle a resynchronization event - proc->symbol_mask[*subframe] = 0; - proc->symbol_mask[(9+*subframe)%10]= 0; // to handle a resynchronization event + if (eNB->CC_id==1) LOG_I(PHY,"Clearing symbol_mask[%d]\n",*subframe); - if (eNB->CC_id==1) LOG_I(PHY,"Clearing symbol_mask[%d]\n",*subframe); + //caculate timestamp_rx, timestamp_tx based on frame and subframe + proc->timestamp_rx = ((proc->frame_rx * 10) + proc->subframe_rx ) * fp->samples_per_tti ; + proc->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); - //caculate timestamp_rx, timestamp_tx based on frame and subframe - proc->timestamp_rx = ((proc->frame_rx * 10) + proc->subframe_rx ) * fp->samples_per_tti ; - proc->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); - - - if (proc->first_rx == 0) { - if (proc->subframe_rx != *subframe){ - LOG_E(PHY,"rx_fh_if4p5, CC_id %d: Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d,CCid %d)\n",eNB->CC_id,proc->subframe_rx,*subframe,eNB->CC_id); - } - if (proc->frame_rx != *frame) { - if (proc->frame_rx == proc->frame_offset) // This means that the RRU has adjusted its frame timing - proc->frame_offset = 0; - else - LOG_E(PHY,"rx_fh_if4p5: Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d,CCid %d)\n",proc->frame_rx,*frame,eNB->CC_id); + + if (proc->first_rx == 0) { + if (proc->subframe_rx != *subframe) { + LOG_E(PHY,"rx_fh_if4p5, CC_id %d: Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d,CCid %d)\n",eNB->CC_id,proc->subframe_rx,*subframe,eNB->CC_id); + } + if (proc->frame_rx != *frame) { + if (proc->frame_rx == proc->frame_offset) // This means that the RRU has adjusted its frame timing + proc->frame_offset = 0; + else + LOG_E(PHY,"rx_fh_if4p5: Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d,CCid %d)\n",proc->frame_rx,*frame,eNB->CC_id); + } + } else { + proc->first_rx = 0; + if (eNB->CC_id==0) + proc->frame_offset = 0; + else + proc->frame_offset = PHY_vars_eNB_g[0][0]->proc.frame_rx; + + *frame = proc->frame_rx;//(proc->frame_rx + proc->frame_offset)&1023; + *subframe = proc->subframe_rx; } - } else { - proc->first_rx = 0; - if (eNB->CC_id==0) - proc->frame_offset = 0; - else - proc->frame_offset = PHY_vars_eNB_g[0][0]->proc.frame_rx; - *frame = proc->frame_rx;//(proc->frame_rx + proc->frame_offset)&1023; - *subframe = proc->subframe_rx; - } - - if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); - + if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); + } void rx_fh_slave(PHY_VARS_eNB *eNB,int *frame,int *subframe) { - // This case is for synchronization to another thread - // it just waits for an external event. The actual rx_fh is handle by the asynchronous RX thread - eNB_proc_t *proc=&eNB->proc; + // This case is for synchronization to another thread + // it just waits for an external event. The actual rx_fh is handle by the asynchronous RX thread + eNB_proc_t *proc=&eNB->proc; + + if (wait_on_condition(&proc->mutex_FH,&proc->cond_FH,&proc->instance_cnt_FH,"rx_fh_slave") < 0) + return; - if (wait_on_condition(&proc->mutex_FH,&proc->cond_FH,&proc->instance_cnt_FH,"rx_fh_slave") < 0) - return; + release_thread(&proc->mutex_FH,&proc->instance_cnt_FH,"rx_fh_slave"); - release_thread(&proc->mutex_FH,&proc->instance_cnt_FH,"rx_fh_slave"); - } int wakeup_rxtx(eNB_proc_t *proc,eNB_rxtx_proc_t *proc_rxtx,LTE_DL_FRAME_PARMS *fp) { - int i; - struct timespec wait; - - wait.tv_sec=0; - 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" ); - 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 ); - exit_fun( "error locking mutex_rxtx" ); - return(-1); - } - - ++proc_rxtx->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 - // transmitted timestamp of the next TX slot (first). - // 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->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; - - // 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 i; + struct timespec wait; + + wait.tv_sec=0; + 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" ); + 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 ); + exit_fun( "error locking mutex_rxtx" ); + return(-1); + } + + ++proc_rxtx->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 + // transmitted timestamp of the next TX slot (first). + // 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->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; + + // 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); } void wakeup_slaves(eNB_proc_t *proc) { - int i; - struct timespec wait; - - wait.tv_sec=0; - wait.tv_nsec=5000000L; - - for (i=0;i<proc->num_slaves;i++) { - eNB_proc_t *slave_proc = proc->slave_proc[i]; - // wake up slave FH thread - // lock the FH mutex and make sure the thread is ready - if (pthread_mutex_timedlock(&slave_proc->mutex_FH,&wait) != 0) { - /* TODO: fix this log, what is 'IC'? */ - /*LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB CCid %d slave CCid %d (IC %d)\n",proc->CC_id,slave_proc->CC_id);*/ - LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB CCid %d slave CCid %d\n",proc->CC_id,slave_proc->CC_id); - exit_fun( "error locking mutex_rxtx" ); - break; + int i; + struct timespec wait; + + wait.tv_sec=0; + wait.tv_nsec=5000000L; + + for (i=0; i<proc->num_slaves; i++) { + eNB_proc_t *slave_proc = proc->slave_proc[i]; + // wake up slave FH thread + // lock the FH mutex and make sure the thread is ready + if (pthread_mutex_timedlock(&slave_proc->mutex_FH,&wait) != 0) { + /* TODO: fix this log, what is 'IC'? */ + /*LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB CCid %d slave CCid %d (IC %d)\n",proc->CC_id,slave_proc->CC_id);*/ + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB CCid %d slave CCid %d\n",proc->CC_id,slave_proc->CC_id); + exit_fun( "error locking mutex_rxtx" ); + break; + } + + while (slave_proc->instance_cnt_FH == 0) { + // LOG_W( PHY,"[eNB] Frame:%d , eNB rx_fh_slave thread busy!! (cnt_FH %i)\n", proc->frame_rx,slave_proc->instance_cnt_FH ); + usleep(500); + } + + int cnt_slave = ++slave_proc->instance_cnt_FH; + slave_proc->frame_rx = proc->frame_rx; + slave_proc->subframe_rx = proc->subframe_rx; + //slave_proc->timestamp_rx = proc->timestamp_rx; + slave_proc->timestamp_tx = proc->timestamp_tx; + + pthread_mutex_unlock( &slave_proc->mutex_FH ); + + if (cnt_slave == 0) { + // the thread was presumably waiting where it should and can now be woken up + if (pthread_cond_signal(&slave_proc->cond_FH) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB CCid %d, slave CCid %d\n",proc->CC_id,slave_proc->CC_id); + exit_fun( "ERROR pthread_cond_signal" ); + break; + } + } else { + LOG_W( PHY,"[eNB] Frame %d, slave CC_id %d thread busy!! (cnt_FH %i)\n",slave_proc->frame_rx,slave_proc->CC_id, cnt_slave); + exit_fun( "FH thread busy" ); + break; + } } - - while (slave_proc->instance_cnt_FH == 0) { - // LOG_W( PHY,"[eNB] Frame:%d , eNB rx_fh_slave thread busy!! (cnt_FH %i)\n", proc->frame_rx,slave_proc->instance_cnt_FH ); - usleep(500); - } - - int cnt_slave = ++slave_proc->instance_cnt_FH; - slave_proc->frame_rx = proc->frame_rx; - slave_proc->subframe_rx = proc->subframe_rx; - //slave_proc->timestamp_rx = proc->timestamp_rx; - slave_proc->timestamp_tx = proc->timestamp_tx; - - pthread_mutex_unlock( &slave_proc->mutex_FH ); - - if (cnt_slave == 0) { - // the thread was presumably waiting where it should and can now be woken up - if (pthread_cond_signal(&slave_proc->cond_FH) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB CCid %d, slave CCid %d\n",proc->CC_id,slave_proc->CC_id); - exit_fun( "ERROR pthread_cond_signal" ); - break; - } - } else { - LOG_W( PHY,"[eNB] Frame %d, slave CC_id %d thread busy!! (cnt_FH %i)\n",slave_proc->frame_rx,slave_proc->CC_id, cnt_slave); - exit_fun( "FH thread busy" ); - break; - } - } } uint32_t sync_corr[307200] __attribute__((aligned(32))); @@ -1265,110 +1209,109 @@ uint32_t sync_corr[307200] __attribute__((aligned(32))); // This thread run the initial synchronization like a UE void *eNB_thread_synch(void *arg) { - PHY_VARS_eNB *eNB = (PHY_VARS_eNB*)arg; - LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; - int32_t sync_pos,sync_pos2; - uint32_t peak_val; - - thread_top_init("eNB_thread_synch",0,5000000,10000000,10000000); - - wait_sync("eNB_thread_synch"); - - // initialize variables for PSS detection - lte_sync_time_init(&eNB->frame_parms); - - while (!oai_exit) { - - // wait to be woken up - pthread_mutex_lock(&eNB->proc.mutex_synch); - while (eNB->proc.instance_cnt_synch < 0) - pthread_cond_wait(&eNB->proc.cond_synch,&eNB->proc.mutex_synch); - pthread_mutex_unlock(&eNB->proc.mutex_synch); - - // if we're not in synch, then run initial synch - if (eNB->in_synch == 0) { - // run intial synch like UE - LOG_I(PHY,"Running initial synchronization\n"); - - sync_pos = lte_sync_time_eNB(eNB->common_vars.rxdata[0], - fp, - fp->samples_per_tti*5, - &peak_val, - sync_corr); - LOG_I(PHY,"eNB synch: %d, val %d\n",sync_pos,peak_val); - - 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; - - if (fp->frame_type == FDD) { - - // PSS is hypothesized in last symbol of first slot in Frame - int sync_pos_slot = (fp->samples_per_tti>>1) - fp->ofdm_symbol_size - fp->nb_prefix_samples; - - if (sync_pos2 >= sync_pos_slot) - eNB->rx_offset = sync_pos2 - sync_pos_slot; - else - eNB->rx_offset = (fp->samples_per_tti*10) + sync_pos2 - sync_pos_slot; - } - else { - - } - - LOG_I(PHY,"Estimated sync_pos %d, peak_val %d => timing offset %d\n",sync_pos,peak_val,eNB->rx_offset); - - /* - if ((peak_val > 300000) && (sync_pos > 0)) { - // if (sync_pos++ > 3) { - write_output("eNB_sync.m","sync",(void*)&sync_corr[0],fp->samples_per_tti*5,1,2); - write_output("eNB_rx.m","rxs",(void*)eNB->common_vars.rxdata[0][0],fp->samples_per_tti*10,1,1); - exit(-1); - } - */ - eNB->in_synch=1; - } - } + PHY_VARS_eNB *eNB = (PHY_VARS_eNB*)arg; + LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; + int32_t sync_pos,sync_pos2; + uint32_t peak_val; + + thread_top_init("eNB_thread_synch",0,5000000,10000000,10000000); + + wait_sync("eNB_thread_synch"); + + // initialize variables for PSS detection + lte_sync_time_init(&eNB->frame_parms); + + while (!oai_exit) { + + // wait to be woken up + pthread_mutex_lock(&eNB->proc.mutex_synch); + while (eNB->proc.instance_cnt_synch < 0) + pthread_cond_wait(&eNB->proc.cond_synch,&eNB->proc.mutex_synch); + pthread_mutex_unlock(&eNB->proc.mutex_synch); + + // if we're not in synch, then run initial synch + if (eNB->in_synch == 0) { + // run intial synch like UE + LOG_I(PHY,"Running initial synchronization\n"); + + sync_pos = lte_sync_time_eNB(eNB->common_vars.rxdata[0], + fp, + fp->samples_per_tti*5, + &peak_val, + sync_corr); + LOG_I(PHY,"eNB synch: %d, val %d\n",sync_pos,peak_val); + + 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; + + if (fp->frame_type == FDD) { + + // PSS is hypothesized in last symbol of first slot in Frame + int sync_pos_slot = (fp->samples_per_tti>>1) - fp->ofdm_symbol_size - fp->nb_prefix_samples; + + if (sync_pos2 >= sync_pos_slot) + eNB->rx_offset = sync_pos2 - sync_pos_slot; + else + eNB->rx_offset = (fp->samples_per_tti*10) + sync_pos2 - sync_pos_slot; + } else { + + } + + LOG_I(PHY,"Estimated sync_pos %d, peak_val %d => timing offset %d\n",sync_pos,peak_val,eNB->rx_offset); + + /* + if ((peak_val > 300000) && (sync_pos > 0)) { + // if (sync_pos++ > 3) { + write_output("eNB_sync.m","sync",(void*)&sync_corr[0],fp->samples_per_tti*5,1,2); + write_output("eNB_rx.m","rxs",(void*)eNB->common_vars.rxdata[0][0],fp->samples_per_tti*10,1,1); + exit(-1); + } + */ + eNB->in_synch=1; + } + } - // release thread - pthread_mutex_lock(&eNB->proc.mutex_synch); - eNB->proc.instance_cnt_synch--; - pthread_mutex_unlock(&eNB->proc.mutex_synch); - } // oai_exit + // release thread + pthread_mutex_lock(&eNB->proc.mutex_synch); + eNB->proc.instance_cnt_synch--; + pthread_mutex_unlock(&eNB->proc.mutex_synch); + } // oai_exit - lte_sync_time_free(); + lte_sync_time_free(); - return NULL; + return NULL; } -int wakeup_synch(PHY_VARS_eNB *eNB){ - - struct timespec wait; - - wait.tv_sec=0; - wait.tv_nsec=5000000L; - - // wake up synch thread - // lock the synch mutex and make sure the thread is ready - if (pthread_mutex_timedlock(&eNB->proc.mutex_synch,&wait) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB synch thread (IC %d)\n", eNB->proc.instance_cnt_synch ); - exit_fun( "error locking mutex_synch" ); - return(-1); - } - - ++eNB->proc.instance_cnt_synch; - - // the thread can now be woken up - if (pthread_cond_signal(&eNB->proc.cond_synch) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB synch thread\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return(-1); - } - - pthread_mutex_unlock( &eNB->proc.mutex_synch ); - - return(0); +int wakeup_synch(PHY_VARS_eNB *eNB) { + + struct timespec wait; + + wait.tv_sec=0; + wait.tv_nsec=5000000L; + + // wake up synch thread + // lock the synch mutex and make sure the thread is ready + if (pthread_mutex_timedlock(&eNB->proc.mutex_synch,&wait) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB synch thread (IC %d)\n", eNB->proc.instance_cnt_synch ); + exit_fun( "error locking mutex_synch" ); + return(-1); + } + + ++eNB->proc.instance_cnt_synch; + + // the thread can now be woken up + if (pthread_cond_signal(&eNB->proc.cond_synch) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB synch thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return(-1); + } + + pthread_mutex_unlock( &eNB->proc.mutex_synch ); + + return(0); } /*! @@ -1380,81 +1323,81 @@ int wakeup_synch(PHY_VARS_eNB *eNB){ */ static void* eNB_thread_FH( void* param ) { - - static int eNB_thread_FH_status; - eNB_proc_t *proc = (eNB_proc_t*)param; - PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id]; - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + static int eNB_thread_FH_status; + + eNB_proc_t *proc = (eNB_proc_t*)param; + PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id]; + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - int subframe=0, frame=0; + int subframe=0, frame=0; - // set default return value - eNB_thread_FH_status = 0; + // set default return value + eNB_thread_FH_status = 0; - thread_top_init("eNB_thread_FH",0,870000,1000000,1000000); + thread_top_init("eNB_thread_FH",0,870000,1000000,1000000); - wait_sync("eNB_thread_FH"); + wait_sync("eNB_thread_FH"); #if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME) - if (eNB->node_function < NGFI_RRU_IF5) - wait_system_ready ("Waiting for eNB application to be ready %s\r", &start_eNB); -#endif - - // Start IF device if any - if (eNB->start_if) - if (eNB->start_if(eNB) != 0) - LOG_E(HW,"Could not start the IF device\n"); - - // Start RF device if any - if (eNB->start_rf) - if (eNB->start_rf(eNB) != 0) - LOG_E(HW,"Could not start the RF device\n"); - - // wakeup asnych_rxtx thread because the devices are ready at this point - 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); - - // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices - while (!oai_exit) { - - // 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 FH interface, acquire signals/data and block - if (eNB->rx_fh) eNB->rx_fh(eNB,&frame,&subframe); - else AssertFatal(1==0, "No fronthaul interface : eNB->node_function %d",eNB->node_function); - - T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx)); - - // 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); - - // wake up RXn_TXnp4 thread for the subframe - // choose even or odd thread for RXn-TXnp4 processing - if (wakeup_rxtx(proc,&proc->proc_rxtx[proc->subframe_rx&1],fp) < 0) - break; - - // artifical sleep for very slow fronthaul - if (eNB->frame_parms.N_RB_DL==6) - rt_sleep_ns(800000LL); - } - - printf( "Exiting FH thread \n"); - - eNB_thread_FH_status = 0; - return &eNB_thread_FH_status; + if (eNB->node_function < NGFI_RRU_IF5) + wait_system_ready ("Waiting for eNB application to be ready %s\r", &start_eNB); +#endif + + // Start IF device if any + if (eNB->start_if) + if (eNB->start_if(eNB) != 0) + LOG_E(HW,"Could not start the IF device\n"); + + // Start RF device if any + if (eNB->start_rf) + if (eNB->start_rf(eNB) != 0) + LOG_E(HW,"Could not start the RF device\n"); + + // wakeup asnych_rxtx thread because the devices are ready at this point + 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); + + // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices + while (!oai_exit) { + + // 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 FH interface, acquire signals/data and block + if (eNB->rx_fh) eNB->rx_fh(eNB,&frame,&subframe); + else AssertFatal(1==0, "No fronthaul interface : eNB->node_function %d",eNB->node_function); + + T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx)); + + // 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); + + // wake up RXn_TXnp4 thread for the subframe + // choose even or odd thread for RXn-TXnp4 processing + if (wakeup_rxtx(proc,&proc->proc_rxtx[proc->subframe_rx&1],fp) < 0) + break; + + // artifical sleep for very slow fronthaul + if (eNB->frame_parms.N_RB_DL==6) + rt_sleep_ns(800000LL); + } + + printf( "Exiting FH thread \n"); + + eNB_thread_FH_status = 0; + return &eNB_thread_FH_status; } @@ -1464,332 +1407,326 @@ static void* eNB_thread_FH( void* param ) { * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ static void* eNB_thread_prach( void* param ) { - static int eNB_thread_prach_status; + static int eNB_thread_prach_status; - eNB_proc_t *proc = (eNB_proc_t*)param; - PHY_VARS_eNB *eNB= PHY_vars_eNB_g[0][proc->CC_id]; + eNB_proc_t *proc = (eNB_proc_t*)param; + PHY_VARS_eNB *eNB= PHY_vars_eNB_g[0][proc->CC_id]; - // set default return value - eNB_thread_prach_status = 0; + // 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,500000L,1000000L,20000000L); - while (!oai_exit) { - - if (oai_exit) break; + while (!oai_exit) { - if (wait_on_condition(&proc->mutex_prach,&proc->cond_prach,&proc->instance_cnt_prach,"eNB_prach_thread") < 0) break; - - prach_procedures(eNB); - - if (release_thread(&proc->mutex_prach,&proc->instance_cnt_prach,"eNB_prach_thread") < 0) break; - } + if (oai_exit) break; + + if (wait_on_condition(&proc->mutex_prach,&proc->cond_prach,&proc->instance_cnt_prach,"eNB_prach_thread") < 0) break; + + prach_procedures(eNB); + + if (release_thread(&proc->mutex_prach,&proc->instance_cnt_prach,"eNB_prach_thread") < 0) break; + } - printf( "Exiting eNB thread PRACH\n"); + printf( "Exiting eNB thread PRACH\n"); - eNB_thread_prach_status = 0; - return &eNB_thread_prach_status; + eNB_thread_prach_status = 0; + return &eNB_thread_prach_status; } static void* eNB_thread_single( void* param ) { - static int eNB_thread_single_status; + static int eNB_thread_single_status; - eNB_proc_t *proc = (eNB_proc_t*)param; - eNB_rxtx_proc_t *proc_rxtx = &proc->proc_rxtx[0]; - PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id]; - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - eNB->CC_id = proc->CC_id; + eNB_proc_t *proc = (eNB_proc_t*)param; + eNB_rxtx_proc_t *proc_rxtx = &proc->proc_rxtx[0]; + PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id]; + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + eNB->CC_id = proc->CC_id; - void *rxp[2],*rxp2[2]; + void *rxp[2],*rxp2[2]; - int subframe=0, frame=0; + int subframe=0, frame=0; - int32_t dummy_rx[fp->nb_antennas_rx][fp->samples_per_tti] __attribute__((aligned(32))); + int32_t dummy_rx[fp->nb_antennas_rx][fp->samples_per_tti] __attribute__((aligned(32))); - int ic; + int ic; - int rxs; + int rxs; - int i; + int i; - // initialize the synchronization buffer to the common_vars.rxdata - for (int i=0;i<fp->nb_antennas_rx;i++) - rxp[i] = &eNB->common_vars.rxdata[0][i][0]; + // initialize the synchronization buffer to the common_vars.rxdata + for (int i=0; i<fp->nb_antennas_rx; i++) + rxp[i] = &eNB->common_vars.rxdata[0][i][0]; - // set default return value - eNB_thread_single_status = 0; + // set default return value + eNB_thread_single_status = 0; - thread_top_init("eNB_thread_single",0,870000,1000000,1000000); + thread_top_init("eNB_thread_single",0,870000,1000000,1000000); - wait_sync("eNB_thread_single"); + wait_sync("eNB_thread_single"); #if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME) - if (eNB->node_function < NGFI_RRU_IF5) - wait_system_ready ("Waiting for eNB application to be ready %s\r", &start_eNB); -#endif - - // Start IF device if any - if (eNB->start_if) - if (eNB->start_if(eNB) != 0) - LOG_E(HW,"Could not start the IF device\n"); - - // Start RF device if any - if (eNB->start_rf) - if (eNB->start_rf(eNB) != 0) - LOG_E(HW,"Could not start the RF device\n"); - - // wakeup asnych_rxtx thread because the devices are ready at this point - 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); - - - - // if this is a slave eNB, try to synchronize on the DL frequency - if ((eNB->is_slave) && - ((eNB->node_function >= NGFI_RRU_IF5))) { - // if FDD, switch RX on DL frequency - - double temp_freq1 = eNB->rfdevice.openair0_cfg->rx_freq[0]; - double temp_freq2 = eNB->rfdevice.openair0_cfg->tx_freq[0]; - for (i=0;i<4;i++) { - eNB->rfdevice.openair0_cfg->rx_freq[i] = eNB->rfdevice.openair0_cfg->tx_freq[i]; - eNB->rfdevice.openair0_cfg->tx_freq[i] = temp_freq1; - } - eNB->rfdevice.trx_set_freq_func(&eNB->rfdevice,eNB->rfdevice.openair0_cfg,0); - - while ((eNB->in_synch ==0)&&(!oai_exit)) { - // read in frame - rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, - &(proc->timestamp_rx), - rxp, - fp->samples_per_tti*10, - fp->nb_antennas_rx); - - if (rxs != (fp->samples_per_tti*10)) - exit_fun("Problem receiving samples\n"); - - // wakeup synchronization processing thread - wakeup_synch(eNB); - ic=0; - - while ((ic>=0)&&(!oai_exit)) { - // continuously read in frames, 1ms at a time, - // until we are done with the synchronization procedure - - for (i=0; i<fp->nb_antennas_rx; i++) - rxp2[i] = (void*)&dummy_rx[i][0]; - for (i=0;i<10;i++) - rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, - &(proc->timestamp_rx), - rxp2, - fp->samples_per_tti, - fp->nb_antennas_rx); - if (rxs != fp->samples_per_tti) - exit_fun( "problem receiving samples" ); - - pthread_mutex_lock(&eNB->proc.mutex_synch); - ic = eNB->proc.instance_cnt_synch; - pthread_mutex_unlock(&eNB->proc.mutex_synch); - } // ic>=0 - } // in_synch==0 - // read in rx_offset samples - LOG_I(PHY,"Resynchronizing by %d samples\n",eNB->rx_offset); - rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, - &(proc->timestamp_rx), - rxp, - eNB->rx_offset, - fp->nb_antennas_rx); - if (rxs != eNB->rx_offset) - exit_fun( "problem receiving samples" ); - - for (i=0;i<4;i++) { - eNB->rfdevice.openair0_cfg->rx_freq[i] = temp_freq1; - eNB->rfdevice.openair0_cfg->tx_freq[i] = temp_freq2; + if (eNB->node_function < NGFI_RRU_IF5) + wait_system_ready ("Waiting for eNB application to be ready %s\r", &start_eNB); +#endif + + // Start IF device if any + if (eNB->start_if) + if (eNB->start_if(eNB) != 0) + LOG_E(HW,"Could not start the IF device\n"); + + // Start RF device if any + if (eNB->start_rf) + if (eNB->start_rf(eNB) != 0) + LOG_E(HW,"Could not start the RF device\n"); + + // wakeup asnych_rxtx thread because the devices are ready at this point + 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); + + + + // if this is a slave eNB, try to synchronize on the DL frequency + if ((eNB->is_slave) && + ((eNB->node_function >= NGFI_RRU_IF5))) { + // if FDD, switch RX on DL frequency + + double temp_freq1 = eNB->rfdevice.openair0_cfg->rx_freq[0]; + double temp_freq2 = eNB->rfdevice.openair0_cfg->tx_freq[0]; + for (i=0; i<4; i++) { + eNB->rfdevice.openair0_cfg->rx_freq[i] = eNB->rfdevice.openair0_cfg->tx_freq[i]; + eNB->rfdevice.openair0_cfg->tx_freq[i] = temp_freq1; + } + eNB->rfdevice.trx_set_freq_func(&eNB->rfdevice,eNB->rfdevice.openair0_cfg,0); + + while ((eNB->in_synch ==0)&&(!oai_exit)) { + // read in frame + rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, + &(proc->timestamp_rx), + rxp, + fp->samples_per_tti*10, + fp->nb_antennas_rx); + + if (rxs != (fp->samples_per_tti*10)) + exit_fun("Problem receiving samples\n"); + + // wakeup synchronization processing thread + wakeup_synch(eNB); + ic=0; + + while ((ic>=0)&&(!oai_exit)) { + // continuously read in frames, 1ms at a time, + // until we are done with the synchronization procedure + + for (i=0; i<fp->nb_antennas_rx; i++) + rxp2[i] = (void*)&dummy_rx[i][0]; + for (i=0; i<10; i++) + rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, + &(proc->timestamp_rx), + rxp2, + fp->samples_per_tti, + fp->nb_antennas_rx); + if (rxs != fp->samples_per_tti) + exit_fun( "problem receiving samples" ); + + pthread_mutex_lock(&eNB->proc.mutex_synch); + ic = eNB->proc.instance_cnt_synch; + pthread_mutex_unlock(&eNB->proc.mutex_synch); + } // ic>=0 + } // in_synch==0 + // read in rx_offset samples + LOG_I(PHY,"Resynchronizing by %d samples\n",eNB->rx_offset); + rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, + &(proc->timestamp_rx), + rxp, + eNB->rx_offset, + fp->nb_antennas_rx); + if (rxs != eNB->rx_offset) + exit_fun( "problem receiving samples" ); + + for (i=0; i<4; i++) { + eNB->rfdevice.openair0_cfg->rx_freq[i] = temp_freq1; + eNB->rfdevice.openair0_cfg->tx_freq[i] = temp_freq2; + } + eNB->rfdevice.trx_set_freq_func(&eNB->rfdevice,eNB->rfdevice.openair0_cfg,1); + } // if RRU and slave + + + // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices + while (!oai_exit) { + + // 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++; + } + + if (eNB->CC_id==1) + LOG_D(PHY,"eNB thread single %p (proc %p, CC_id %d), frame %d (%p), subframe %d (%p)\n", + pthread_self(), proc, eNB->CC_id, frame,&frame,subframe,&subframe); + + // synchronization on FH interface, acquire signals/data and block + if (eNB->rx_fh) eNB->rx_fh(eNB,&frame,&subframe); + else AssertFatal(1==0, "No fronthaul interface : eNB->node_function %d",eNB->node_function); + + 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+4)%10; + proc_rxtx->frame_tx = (proc->subframe_rx>5) ? (1+proc->frame_rx)&1023 : proc->frame_rx; + proc->frame_tx = proc_rxtx->frame_tx; + proc_rxtx->timestamp_tx = proc->timestamp_tx; + // adjust for timing offset between RRU + if (eNB->CC_id!=0) proc_rxtx->frame_tx = (proc_rxtx->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); + + if (rxtx(eNB,proc_rxtx,"eNB_thread_single") < 0) break; } - eNB->rfdevice.trx_set_freq_func(&eNB->rfdevice,eNB->rfdevice.openair0_cfg,1); - } // if RRU and slave - // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices - while (!oai_exit) { + printf( "Exiting eNB_single thread \n"); - // 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++; - } - - if (eNB->CC_id==1) - LOG_D(PHY,"eNB thread single %p (proc %p, CC_id %d), frame %d (%p), subframe %d (%p)\n", - pthread_self(), proc, eNB->CC_id, frame,&frame,subframe,&subframe); - - // synchronization on FH interface, acquire signals/data and block - if (eNB->rx_fh) eNB->rx_fh(eNB,&frame,&subframe); - else AssertFatal(1==0, "No fronthaul interface : eNB->node_function %d",eNB->node_function); - - 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+4)%10; - proc_rxtx->frame_tx = (proc->subframe_rx>5) ? (1+proc->frame_rx)&1023 : proc->frame_rx; - proc->frame_tx = proc_rxtx->frame_tx; - proc_rxtx->timestamp_tx = proc->timestamp_tx; - // adjust for timing offset between RRU - if (eNB->CC_id!=0) proc_rxtx->frame_tx = (proc_rxtx->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); - - if (rxtx(eNB,proc_rxtx,"eNB_thread_single") < 0) break; - } - - - printf( "Exiting eNB_single thread \n"); - - eNB_thread_single_status = 0; - return &eNB_thread_single_status; + eNB_thread_single_status = 0; + return &eNB_thread_single_status; } -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 *); - void init_eNB_proc(int inst) { - - int i=0; - int CC_id; - PHY_VARS_eNB *eNB; - eNB_proc_t *proc; - eNB_rxtx_proc_t *proc_rxtx; - pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_FH=NULL,*attr_prach=NULL,*attr_asynch=NULL,*attr_single=NULL,*attr_fep=NULL,*attr_td=NULL,*attr_te=NULL,*attr_synch=NULL; - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - eNB = PHY_vars_eNB_g[inst][CC_id]; + + int i=0; + int CC_id; + PHY_VARS_eNB *eNB; + eNB_proc_t *proc; + eNB_rxtx_proc_t *proc_rxtx; + pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_FH=NULL,*attr_prach=NULL,*attr_asynch=NULL,*attr_single=NULL,*attr_fep=NULL,*attr_td=NULL,*attr_te=NULL,*attr_synch=NULL; + + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + eNB = PHY_vars_eNB_g[inst][CC_id]; #ifndef OCP_FRAMEWORK - LOG_I(PHY,"Initializing eNB %d CC_id %d (%s,%s),\n",inst,CC_id,eNB_functions[eNB->node_function],eNB_timing[eNB->node_timing]); + LOG_I(PHY,"Initializing eNB %d CC_id %d (%s,%s),\n",inst,CC_id,eNB_functions[eNB->node_function],eNB_timing[eNB->node_timing]); #endif - proc = &eNB->proc; - - proc_rxtx = proc->proc_rxtx; - proc_rxtx[0].instance_cnt_rxtx = -1; - proc_rxtx[1].instance_cnt_rxtx = -1; - proc->instance_cnt_prach = -1; - proc->instance_cnt_FH = -1; - proc->instance_cnt_asynch_rxtx = -1; - proc->CC_id = CC_id; - proc->instance_cnt_synch = -1; - - proc->first_rx=1; - proc->first_tx=1; - proc->frame_offset = 0; - - for (i=0;i<10;i++) proc->symbol_mask[i]=0; - - pthread_mutex_init( &proc_rxtx[0].mutex_rxtx, NULL); - pthread_mutex_init( &proc_rxtx[1].mutex_rxtx, NULL); - pthread_cond_init( &proc_rxtx[0].cond_rxtx, NULL); - pthread_cond_init( &proc_rxtx[1].cond_rxtx, NULL); - - pthread_mutex_init( &proc->mutex_prach, NULL); - pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL); - pthread_mutex_init( &proc->mutex_synch,NULL); - - pthread_cond_init( &proc->cond_prach, NULL); - pthread_cond_init( &proc->cond_FH, 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_prach); - pthread_attr_init( &proc->attr_synch); - pthread_attr_init( &proc->attr_asynch_rxtx); - pthread_attr_init( &proc->attr_single); - pthread_attr_init( &proc->attr_fep); - 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); + proc = &eNB->proc; + + proc_rxtx = proc->proc_rxtx; + proc_rxtx[0].instance_cnt_rxtx = -1; + proc_rxtx[1].instance_cnt_rxtx = -1; + proc->instance_cnt_prach = -1; + proc->instance_cnt_FH = -1; + proc->instance_cnt_asynch_rxtx = -1; + proc->CC_id = CC_id; + proc->instance_cnt_synch = -1; + + proc->first_rx=1; + proc->first_tx=1; + proc->frame_offset = 0; + + for (i=0; i<10; i++) proc->symbol_mask[i]=0; + + pthread_mutex_init( &proc_rxtx[0].mutex_rxtx, NULL); + pthread_mutex_init( &proc_rxtx[1].mutex_rxtx, NULL); + pthread_cond_init( &proc_rxtx[0].cond_rxtx, NULL); + pthread_cond_init( &proc_rxtx[1].cond_rxtx, NULL); + + pthread_mutex_init( &proc->mutex_prach, NULL); + pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL); + pthread_mutex_init( &proc->mutex_synch,NULL); + + pthread_cond_init( &proc->cond_prach, NULL); + pthread_cond_init( &proc->cond_FH, 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_prach); + pthread_attr_init( &proc->attr_synch); + pthread_attr_init( &proc->attr_asynch_rxtx); + pthread_attr_init( &proc->attr_single); + pthread_attr_init( &proc->attr_fep); + 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); #ifndef DEADLINE_SCHEDULER - attr0 = &proc_rxtx[0].attr_rxtx; - attr1 = &proc_rxtx[1].attr_rxtx; - attr_FH = &proc->attr_FH; - attr_prach = &proc->attr_prach; - attr_synch = &proc->attr_synch; - attr_asynch = &proc->attr_asynch_rxtx; - attr_single = &proc->attr_single; - attr_fep = &proc->attr_fep; - attr_td = &proc->attr_td; - attr_te = &proc->attr_te; + attr0 = &proc_rxtx[0].attr_rxtx; + attr1 = &proc_rxtx[1].attr_rxtx; + attr_FH = &proc->attr_FH; + attr_prach = &proc->attr_prach; + attr_synch = &proc->attr_synch; + attr_asynch = &proc->attr_asynch_rxtx; + attr_single = &proc->attr_single; + attr_fep = &proc->attr_fep; + attr_td = &proc->attr_td; + attr_te = &proc->attr_te; #endif - 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] ); - pthread_create( &proc->pthread_FH, attr_FH, eNB_thread_FH, &eNB->proc ); - } - else { - pthread_create(&proc->pthread_single, attr_single, eNB_thread_single, &eNB->proc); - init_fep_thread(eNB,attr_fep); - init_td_thread(eNB,attr_td); - init_te_thread(eNB,attr_te); - } - pthread_create( &proc->pthread_prach, attr_prach, eNB_thread_prach, &eNB->proc ); - pthread_create( &proc->pthread_synch, attr_synch, eNB_thread_synch, eNB); - if ((eNB->node_timing == synch_to_other) || - (eNB->node_function == NGFI_RRU_IF5) || - (eNB->node_function == NGFI_RRU_IF4p5)) - - - pthread_create( &proc->pthread_asynch_rxtx, attr_asynch, eNB_thread_asynch_rxtx, &eNB->proc ); - - char name[16]; - if (eNB->single_thread_flag == 0) { - snprintf( name, sizeof(name), "RXTX0 %d", i ); - pthread_setname_np( proc_rxtx[0].pthread_rxtx, name ); - snprintf( name, sizeof(name), "RXTX1 %d", i ); - pthread_setname_np( proc_rxtx[1].pthread_rxtx, name ); - snprintf( name, sizeof(name), "FH %d", i ); - pthread_setname_np( proc->pthread_FH, name ); - } - else { - snprintf( name, sizeof(name), " %d", i ); - pthread_setname_np( proc->pthread_single, name ); + 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] ); + pthread_create( &proc->pthread_FH, attr_FH, eNB_thread_FH, &eNB->proc ); + } else { + pthread_create(&proc->pthread_single, attr_single, eNB_thread_single, &eNB->proc); + init_fep_thread(eNB,attr_fep); + init_td_thread(eNB,attr_td); + init_te_thread(eNB,attr_te); + } + pthread_create( &proc->pthread_prach, attr_prach, eNB_thread_prach, &eNB->proc ); + pthread_create( &proc->pthread_synch, attr_synch, eNB_thread_synch, eNB); + if ((eNB->node_timing == synch_to_other) || + (eNB->node_function == NGFI_RRU_IF5) || + (eNB->node_function == NGFI_RRU_IF4p5)) + + + pthread_create( &proc->pthread_asynch_rxtx, attr_asynch, eNB_thread_asynch_rxtx, &eNB->proc ); + + char name[16]; + if (eNB->single_thread_flag == 0) { + snprintf( name, sizeof(name), "RXTX0 %d", i ); + pthread_setname_np( proc_rxtx[0].pthread_rxtx, name ); + snprintf( name, sizeof(name), "RXTX1 %d", i ); + pthread_setname_np( proc_rxtx[1].pthread_rxtx, name ); + snprintf( name, sizeof(name), "FH %d", i ); + pthread_setname_np( proc->pthread_FH, name ); + } else { + snprintf( name, sizeof(name), " %d", i ); + pthread_setname_np( proc->pthread_single, name ); + } } - } - //for multiple CCs: setup master and slaves - /* - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - eNB = PHY_vars_eNB_g[inst][CC_id]; + //for multiple CCs: setup master and slaves + /* + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + eNB = PHY_vars_eNB_g[inst][CC_id]; - if (eNB->node_timing == synch_to_ext_device) { //master - eNB->proc.num_slaves = MAX_NUM_CCs-1; - eNB->proc.slave_proc = (eNB_proc_t**)malloc(eNB->proc.num_slaves*sizeof(eNB_proc_t*)); + if (eNB->node_timing == synch_to_ext_device) { //master + eNB->proc.num_slaves = MAX_NUM_CCs-1; + eNB->proc.slave_proc = (eNB_proc_t**)malloc(eNB->proc.num_slaves*sizeof(eNB_proc_t*)); - for (i=0; i< eNB->proc.num_slaves; i++) { - if (i < CC_id) eNB->proc.slave_proc[i] = &(PHY_vars_eNB_g[inst][i]->proc); - if (i >= CC_id) eNB->proc.slave_proc[i] = &(PHY_vars_eNB_g[inst][i+1]->proc); - } - } - } -*/ + for (i=0; i< eNB->proc.num_slaves; i++) { + if (i < CC_id) eNB->proc.slave_proc[i] = &(PHY_vars_eNB_g[inst][i]->proc); + if (i >= CC_id) eNB->proc.slave_proc[i] = &(PHY_vars_eNB_g[inst][i+1]->proc); + } + } + } + */ - /* setup PHY proc TX sync mechanism */ - 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; + /* setup PHY proc TX sync mechanism */ + 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; } @@ -1799,45 +1736,45 @@ void init_eNB_proc(int inst) { */ void kill_eNB_proc(int inst) { - int *status; - PHY_VARS_eNB *eNB; - eNB_proc_t *proc; - eNB_rxtx_proc_t *proc_rxtx; - for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - eNB=PHY_vars_eNB_g[inst][CC_id]; - - proc = &eNB->proc; - proc_rxtx = &proc->proc_rxtx[0]; - + int *status; + PHY_VARS_eNB *eNB; + eNB_proc_t *proc; + eNB_rxtx_proc_t *proc_rxtx; + for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + eNB=PHY_vars_eNB_g[inst][CC_id]; + + proc = &eNB->proc; + proc_rxtx = &proc->proc_rxtx[0]; + #ifdef DEBUG_THREADS - printf( "Killing TX CC_id %d thread %d\n", CC_id, i ); + printf( "Killing TX CC_id %d thread %d\n", CC_id, i ); #endif - - proc_rxtx[0].instance_cnt_rxtx = 0; // FIXME data race! - proc_rxtx[1].instance_cnt_rxtx = 0; // FIXME data race! - proc->instance_cnt_prach = 0; - proc->instance_cnt_FH = 0; - pthread_cond_signal( &proc_rxtx[0].cond_rxtx ); - pthread_cond_signal( &proc_rxtx[1].cond_rxtx ); - pthread_cond_signal( &proc->cond_prach ); - pthread_cond_signal( &proc->cond_FH ); - pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx); - - pthread_join( proc->pthread_FH, (void**)&status ); - pthread_mutex_destroy( &proc->mutex_FH ); - pthread_cond_destroy( &proc->cond_FH ); - - pthread_join( proc->pthread_prach, (void**)&status ); - pthread_mutex_destroy( &proc->mutex_prach ); - pthread_cond_destroy( &proc->cond_prach ); - int i; - for (i=0;i<2;i++) { - pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status ); - pthread_mutex_destroy( &proc_rxtx[i].mutex_rxtx ); - pthread_cond_destroy( &proc_rxtx[i].cond_rxtx ); + proc_rxtx[0].instance_cnt_rxtx = 0; // FIXME data race! + proc_rxtx[1].instance_cnt_rxtx = 0; // FIXME data race! + proc->instance_cnt_prach = 0; + proc->instance_cnt_FH = 0; + pthread_cond_signal( &proc_rxtx[0].cond_rxtx ); + pthread_cond_signal( &proc_rxtx[1].cond_rxtx ); + pthread_cond_signal( &proc->cond_prach ); + pthread_cond_signal( &proc->cond_FH ); + pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx); + + pthread_join( proc->pthread_FH, (void**)&status ); + pthread_mutex_destroy( &proc->mutex_FH ); + pthread_cond_destroy( &proc->cond_FH ); + + pthread_join( proc->pthread_prach, (void**)&status ); + pthread_mutex_destroy( &proc->mutex_prach ); + pthread_cond_destroy( &proc->cond_prach ); + + int i; + for (i=0; i<2; i++) { + pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status ); + pthread_mutex_destroy( &proc_rxtx[i].mutex_rxtx ); + pthread_cond_destroy( &proc_rxtx[i].cond_rxtx ); + } } - } } @@ -1847,126 +1784,125 @@ void kill_eNB_proc(int inst) { antennas are mapped to successive RF chains on the same card. */ int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_cfg) { - int i,j; - int CC_id,card,ant; + int i,j; + int CC_id,card,ant; - //uint16_t N_TA_offset = 0; + //uint16_t N_TA_offset = 0; - LTE_DL_FRAME_PARMS *frame_parms; + LTE_DL_FRAME_PARMS *frame_parms; - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - if (phy_vars_eNB[CC_id]) { - frame_parms = &(phy_vars_eNB[CC_id]->frame_parms); - printf("setup_eNB_buffers: frame_parms = %p\n",frame_parms); - } else { - printf("phy_vars_eNB[%d] not initialized\n", CC_id); - return(-1); - } + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + if (phy_vars_eNB[CC_id]) { + frame_parms = &(phy_vars_eNB[CC_id]->frame_parms); + printf("setup_eNB_buffers: frame_parms = %p\n",frame_parms); + } else { + printf("phy_vars_eNB[%d] not initialized\n", CC_id); + return(-1); + } - /* - if (frame_parms->frame_type == TDD) { - if (frame_parms->N_RB_DL == 100) - N_TA_offset = 624; - else if (frame_parms->N_RB_DL == 50) - N_TA_offset = 624/2; - else if (frame_parms->N_RB_DL == 25) - N_TA_offset = 624/4; - } - */ - - - if (openair0_cfg[CC_id].mmapped_dma == 1) { - // replace RX signal buffers with mmaped HW versions - - for (i=0; i<frame_parms->nb_antennas_rx; i++) { - card = i/4; - ant = i%4; - printf("Mapping eNB CC_id %d, rx_ant %d, on card %d, chain %d\n",CC_id,i,phy_vars_eNB[CC_id]->rf_map.card+card, phy_vars_eNB[CC_id]->rf_map.chain+ant); - free(phy_vars_eNB[CC_id]->common_vars.rxdata[0][i]); - phy_vars_eNB[CC_id]->common_vars.rxdata[0][i] = openair0_cfg[phy_vars_eNB[CC_id]->rf_map.card+card].rxbase[phy_vars_eNB[CC_id]->rf_map.chain+ant]; - - printf("rxdata[%d] @ %p\n",i,phy_vars_eNB[CC_id]->common_vars.rxdata[0][i]); - for (j=0; j<16; j++) { - printf("rxbuffer %d: %x\n",j,phy_vars_eNB[CC_id]->common_vars.rxdata[0][i][j]); - phy_vars_eNB[CC_id]->common_vars.rxdata[0][i][j] = 16-j; - } - } - - for (i=0; i<frame_parms->nb_antennas_tx; i++) { - card = i/4; - ant = i%4; - printf("Mapping eNB CC_id %d, tx_ant %d, on card %d, chain %d\n",CC_id,i,phy_vars_eNB[CC_id]->rf_map.card+card, phy_vars_eNB[CC_id]->rf_map.chain+ant); - free(phy_vars_eNB[CC_id]->common_vars.txdata[0][i]); - phy_vars_eNB[CC_id]->common_vars.txdata[0][i] = openair0_cfg[phy_vars_eNB[CC_id]->rf_map.card+card].txbase[phy_vars_eNB[CC_id]->rf_map.chain+ant]; - - printf("txdata[%d] @ %p\n",i,phy_vars_eNB[CC_id]->common_vars.txdata[0][i]); - - for (j=0; j<16; j++) { - printf("txbuffer %d: %x\n",j,phy_vars_eNB[CC_id]->common_vars.txdata[0][i][j]); - phy_vars_eNB[CC_id]->common_vars.txdata[0][i][j] = 16-j; - } - } - } - else { // not memory-mapped DMA - //nothing to do, everything already allocated in lte_init - /* - rxdata = (int32_t**)malloc16(frame_parms->nb_antennas_rx*sizeof(int32_t*)); - txdata = (int32_t**)malloc16(frame_parms->nb_antennas_tx*sizeof(int32_t*)); - - for (i=0; i<frame_parms->nb_antennas_rx; i++) { - free(phy_vars_eNB[CC_id]->common_vars.rxdata[0][i]); - rxdata[i] = (int32_t*)(32 + malloc16(32+frame_parms->samples_per_tti*10*sizeof(int32_t))); // FIXME broken memory allocation - phy_vars_eNB[CC_id]->common_vars.rxdata[0][i] = rxdata[i]; //-N_TA_offset; // N_TA offset for TDD FIXME! N_TA_offset > 16 => access of unallocated memory - memset(rxdata[i], 0, frame_parms->samples_per_tti*10*sizeof(int32_t)); - printf("rxdata[%d] @ %p (%p) (N_TA_OFFSET %d)\n", i, phy_vars_eNB[CC_id]->common_vars.rxdata[0][i],rxdata[i],N_TA_offset); - } - - for (i=0; i<frame_parms->nb_antennas_tx; i++) { - free(phy_vars_eNB[CC_id]->common_vars.txdata[0][i]); - txdata[i] = (int32_t*)(32 + malloc16(32 + frame_parms->samples_per_tti*10*sizeof(int32_t))); // FIXME broken memory allocation - phy_vars_eNB[CC_id]->common_vars.txdata[0][i] = txdata[i]; - memset(txdata[i],0, frame_parms->samples_per_tti*10*sizeof(int32_t)); - printf("txdata[%d] @ %p\n", i, phy_vars_eNB[CC_id]->common_vars.txdata[0][i]); - } - */ + /* + if (frame_parms->frame_type == TDD) { + if (frame_parms->N_RB_DL == 100) + N_TA_offset = 624; + else if (frame_parms->N_RB_DL == 50) + N_TA_offset = 624/2; + else if (frame_parms->N_RB_DL == 25) + N_TA_offset = 624/4; + } + */ + + + if (openair0_cfg[CC_id].mmapped_dma == 1) { + // replace RX signal buffers with mmaped HW versions + + for (i=0; i<frame_parms->nb_antennas_rx; i++) { + card = i/4; + ant = i%4; + printf("Mapping eNB CC_id %d, rx_ant %d, on card %d, chain %d\n",CC_id,i,phy_vars_eNB[CC_id]->rf_map.card+card, phy_vars_eNB[CC_id]->rf_map.chain+ant); + free(phy_vars_eNB[CC_id]->common_vars.rxdata[0][i]); + phy_vars_eNB[CC_id]->common_vars.rxdata[0][i] = openair0_cfg[phy_vars_eNB[CC_id]->rf_map.card+card].rxbase[phy_vars_eNB[CC_id]->rf_map.chain+ant]; + + printf("rxdata[%d] @ %p\n",i,phy_vars_eNB[CC_id]->common_vars.rxdata[0][i]); + for (j=0; j<16; j++) { + printf("rxbuffer %d: %x\n",j,phy_vars_eNB[CC_id]->common_vars.rxdata[0][i][j]); + phy_vars_eNB[CC_id]->common_vars.rxdata[0][i][j] = 16-j; + } + } + + for (i=0; i<frame_parms->nb_antennas_tx; i++) { + card = i/4; + ant = i%4; + printf("Mapping eNB CC_id %d, tx_ant %d, on card %d, chain %d\n",CC_id,i,phy_vars_eNB[CC_id]->rf_map.card+card, phy_vars_eNB[CC_id]->rf_map.chain+ant); + free(phy_vars_eNB[CC_id]->common_vars.txdata[0][i]); + phy_vars_eNB[CC_id]->common_vars.txdata[0][i] = openair0_cfg[phy_vars_eNB[CC_id]->rf_map.card+card].txbase[phy_vars_eNB[CC_id]->rf_map.chain+ant]; + + printf("txdata[%d] @ %p\n",i,phy_vars_eNB[CC_id]->common_vars.txdata[0][i]); + + for (j=0; j<16; j++) { + printf("txbuffer %d: %x\n",j,phy_vars_eNB[CC_id]->common_vars.txdata[0][i][j]); + phy_vars_eNB[CC_id]->common_vars.txdata[0][i][j] = 16-j; + } + } + } else { // not memory-mapped DMA + //nothing to do, everything already allocated in lte_init + /* + rxdata = (int32_t**)malloc16(frame_parms->nb_antennas_rx*sizeof(int32_t*)); + txdata = (int32_t**)malloc16(frame_parms->nb_antennas_tx*sizeof(int32_t*)); + + for (i=0; i<frame_parms->nb_antennas_rx; i++) { + free(phy_vars_eNB[CC_id]->common_vars.rxdata[0][i]); + rxdata[i] = (int32_t*)(32 + malloc16(32+frame_parms->samples_per_tti*10*sizeof(int32_t))); // FIXME broken memory allocation + phy_vars_eNB[CC_id]->common_vars.rxdata[0][i] = rxdata[i]; //-N_TA_offset; // N_TA offset for TDD FIXME! N_TA_offset > 16 => access of unallocated memory + memset(rxdata[i], 0, frame_parms->samples_per_tti*10*sizeof(int32_t)); + printf("rxdata[%d] @ %p (%p) (N_TA_OFFSET %d)\n", i, phy_vars_eNB[CC_id]->common_vars.rxdata[0][i],rxdata[i],N_TA_offset); + } + + for (i=0; i<frame_parms->nb_antennas_tx; i++) { + free(phy_vars_eNB[CC_id]->common_vars.txdata[0][i]); + txdata[i] = (int32_t*)(32 + malloc16(32 + frame_parms->samples_per_tti*10*sizeof(int32_t))); // FIXME broken memory allocation + phy_vars_eNB[CC_id]->common_vars.txdata[0][i] = txdata[i]; + memset(txdata[i],0, frame_parms->samples_per_tti*10*sizeof(int32_t)); + printf("txdata[%d] @ %p\n", i, phy_vars_eNB[CC_id]->common_vars.txdata[0][i]); + } + */ + } } - } - return(0); + return(0); } void reset_opp_meas(void) { - int sfn; - reset_meas(&softmodem_stats_mt); - reset_meas(&softmodem_stats_hw); - - for (sfn=0; sfn < 10; sfn++) { - reset_meas(&softmodem_stats_rxtx_sf); - reset_meas(&softmodem_stats_rx_sf); - } + int sfn; + reset_meas(&softmodem_stats_mt); + reset_meas(&softmodem_stats_hw); + + for (sfn=0; sfn < 10; sfn++) { + reset_meas(&softmodem_stats_rxtx_sf); + reset_meas(&softmodem_stats_rx_sf); + } } void print_opp_meas(void) { - int sfn=0; - print_meas(&softmodem_stats_mt, "Main ENB Thread", NULL, NULL); - print_meas(&softmodem_stats_hw, "HW Acquisation", NULL, NULL); - - for (sfn=0; sfn < 10; sfn++) { - print_meas(&softmodem_stats_rxtx_sf,"[eNB][total_phy_proc_rxtx]",NULL, NULL); - print_meas(&softmodem_stats_rx_sf,"[eNB][total_phy_proc_rx]",NULL,NULL); - } + int sfn=0; + print_meas(&softmodem_stats_mt, "Main ENB Thread", NULL, NULL); + print_meas(&softmodem_stats_hw, "HW Acquisation", NULL, NULL); + + for (sfn=0; sfn < 10; sfn++) { + print_meas(&softmodem_stats_rxtx_sf,"[eNB][total_phy_proc_rxtx]",NULL, NULL); + print_meas(&softmodem_stats_rx_sf,"[eNB][total_phy_proc_rx]",NULL,NULL); + } } - + int start_if(PHY_VARS_eNB *eNB) { - return(eNB->ifdevice.trx_start_func(&eNB->ifdevice)); + return(eNB->ifdevice.trx_start_func(&eNB->ifdevice)); } int start_rf(PHY_VARS_eNB *eNB) { - return(eNB->rfdevice.trx_start_func(&eNB->rfdevice)); + return(eNB->rfdevice.trx_start_func(&eNB->rfdevice)); } extern void eNB_fep_rru_if5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc); @@ -1975,213 +1911,219 @@ extern void eNB_fep_full_2thread(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc); extern void do_prach(PHY_VARS_eNB *eNB,int frame,int subframe); void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst,eth_params_t *eth_params,int single_thread_flag,int wait_for_sync) { - - int CC_id; - int inst; - PHY_VARS_eNB *eNB; - int ret; - - for (inst=0;inst<nb_inst;inst++) { - for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) { - eNB = PHY_vars_eNB_g[inst][CC_id]; - eNB->node_function = node_function[CC_id]; - eNB->node_timing = node_timing[CC_id]; - eNB->abstraction_flag = 0; - eNB->single_thread_flag = single_thread_flag; - eNB->ts_offset = 0; - eNB->in_synch = 0; - eNB->is_slave = (wait_for_sync>0) ? 1 : 0; + int CC_id; + int inst; + PHY_VARS_eNB *eNB; + int ret; -#ifndef OCP_FRAMEWORK - LOG_I(PHY,"Initializing eNB %d CC_id %d : (%s,%s)\n",inst,CC_id,eNB_functions[node_function[CC_id]],eNB_timing[node_timing[CC_id]]); -#endif + for (inst=0; inst<nb_inst; inst++) { + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + eNB = PHY_vars_eNB_g[inst][CC_id]; + eNB->node_function = node_function[CC_id]; + eNB->node_timing = node_timing[CC_id]; + eNB->eth_params = eth_params+CC_id; + eNB->abstraction_flag = 0; + eNB->single_thread_flag = single_thread_flag; + eNB->ts_offset = 0; + eNB->in_synch = 0; + eNB->is_slave = (wait_for_sync>0) ? 1 : 0; - switch (node_function[CC_id]) { - case NGFI_RRU_IF5: - eNB->do_prach = NULL; - eNB->do_precoding = 0; - eNB->fep = eNB_fep_rru_if5; - eNB->td = NULL; - eNB->te = NULL; - eNB->proc_uespec_rx = NULL; - eNB->proc_tx = NULL; - eNB->tx_fh = NULL; - eNB->rx_fh = rx_rf; - eNB->start_rf = start_rf; - eNB->start_if = start_if; - eNB->fh_asynch = fh_if5_asynch_DL; - ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]); - if (ret<0) { - printf("Exiting, cannot initialize rf device\n"); - exit(-1); - } - eNB->rfdevice.host_type = RRH_HOST; - eNB->ifdevice.host_type = RRH_HOST; - ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id)); - printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id); - if (ret<0) { - printf("Exiting, cannot initialize transport protocol\n"); - exit(-1); - } - break; - case NGFI_RRU_IF4p5: - eNB->do_precoding = 0; - eNB->do_prach = do_prach; - eNB->fep = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full; - eNB->td = NULL; - eNB->te = NULL; - eNB->proc_uespec_rx = NULL; - eNB->proc_tx = NULL;//proc_tx_rru_if4p5; - eNB->tx_fh = NULL; - eNB->rx_fh = rx_rf; - eNB->fh_asynch = fh_if4p5_asynch_DL; - eNB->start_rf = start_rf; - eNB->start_if = start_if; - ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]); - if (ret<0) { - printf("Exiting, cannot initialize rf device\n"); - exit(-1); - } - eNB->rfdevice.host_type = RRH_HOST; - eNB->ifdevice.host_type = RRH_HOST; - printf("loading transport interface ...\n"); - ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id)); - printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id); - if (ret<0) { - printf("Exiting, cannot initialize transport protocol\n"); - exit(-1); - } - malloc_IF4p5_buffer(eNB); - - break; - case eNodeB_3GPP: - eNB->do_precoding = eNB->frame_parms.nb_antennas_tx!=eNB->frame_parms.nb_antenna_ports_eNB; - eNB->do_prach = do_prach; - eNB->fep = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full; - 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->proc_uespec_rx = phy_procedures_eNB_uespec_RX; - eNB->proc_tx = proc_tx_full; - eNB->tx_fh = NULL; - eNB->rx_fh = rx_rf; - eNB->start_rf = start_rf; - eNB->start_if = NULL; - eNB->fh_asynch = NULL; - ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]); - if (ret<0) { - printf("Exiting, cannot initialize rf device\n"); - exit(-1); - } - eNB->rfdevice.host_type = BBU_HOST; - eNB->ifdevice.host_type = BBU_HOST; - break; - case eNodeB_3GPP_BBU: - eNB->do_precoding = eNB->frame_parms.nb_antennas_tx!=eNB->frame_parms.nb_antenna_ports_eNB; - eNB->do_prach = do_prach; - eNB->fep = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full; - 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->proc_uespec_rx = phy_procedures_eNB_uespec_RX; - eNB->proc_tx = proc_tx_full; - if (eNB->node_timing == synch_to_other) { - eNB->tx_fh = tx_fh_if5_mobipass; - eNB->rx_fh = rx_fh_slave; - eNB->fh_asynch = fh_if5_asynch_UL; +#ifndef OCP_FRAMEWORK + LOG_I(PHY,"Initializing eNB %d CC_id %d : (%s,%s)\n",inst,CC_id,eNB_functions[node_function[CC_id]],eNB_timing[node_timing[CC_id]]); +#endif + switch (node_function[CC_id]) { + case NGFI_RRU_IF5: + eNB->do_prach = NULL; + eNB->do_precoding = 0; + eNB->fep = eNB_fep_rru_if5; + eNB->td = NULL; + eNB->te = NULL; + eNB->proc_uespec_rx = NULL; + eNB->proc_tx = NULL; + eNB->tx_fh = NULL; + eNB->rx_fh = rx_rf; + eNB->start_rf = start_rf; + eNB->start_if = start_if; + eNB->fh_asynch = fh_if5_asynch_DL; + if (oaisim_flag == 0) { + ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]); + if (ret<0) { + printf("Exiting, cannot initialize rf device\n"); + exit(-1); + } + } + eNB->rfdevice.host_type = RRH_HOST; + eNB->ifdevice.host_type = RRH_HOST; + ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], eNB->eth_params); + printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id); + if (ret<0) { + printf("Exiting, cannot initialize transport protocol\n"); + exit(-1); + } + break; + case NGFI_RRU_IF4p5: + eNB->do_precoding = 0; + eNB->do_prach = do_prach; + eNB->fep = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full; + eNB->td = NULL; + eNB->te = NULL; + eNB->proc_uespec_rx = NULL; + eNB->proc_tx = NULL;//proc_tx_rru_if4p5; + eNB->tx_fh = NULL; + eNB->rx_fh = rx_rf; + eNB->fh_asynch = fh_if4p5_asynch_DL; + eNB->start_rf = start_rf; + eNB->start_if = start_if; + if (oaisim_flag == 0) { + ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]); + if (ret<0) { + printf("Exiting, cannot initialize rf device\n"); + exit(-1); + } + } + eNB->rfdevice.host_type = RRH_HOST; + eNB->ifdevice.host_type = RRH_HOST; + printf("loading transport interface ...\n"); + ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], eNB->eth_params); + printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id); + if (ret<0) { + printf("Exiting, cannot initialize transport protocol\n"); + exit(-1); + } + + malloc_IF4p5_buffer(eNB); + + break; + case eNodeB_3GPP: + eNB->do_precoding = eNB->frame_parms.nb_antennas_tx!=eNB->frame_parms.nb_antenna_ports_eNB; + eNB->do_prach = do_prach; + eNB->fep = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full; + 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->proc_uespec_rx = phy_procedures_eNB_uespec_RX; + eNB->proc_tx = proc_tx_full; + eNB->tx_fh = NULL; + eNB->rx_fh = rx_rf; + eNB->start_rf = start_rf; + eNB->start_if = NULL; + eNB->fh_asynch = NULL; + if (oaisim_flag == 0) { + ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]); + if (ret<0) { + printf("Exiting, cannot initialize rf device\n"); + exit(-1); + } + } + eNB->rfdevice.host_type = BBU_HOST; + eNB->ifdevice.host_type = BBU_HOST; + break; + case eNodeB_3GPP_BBU: + eNB->do_precoding = eNB->frame_parms.nb_antennas_tx!=eNB->frame_parms.nb_antenna_ports_eNB; + eNB->do_prach = do_prach; + eNB->fep = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full; + 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->proc_uespec_rx = phy_procedures_eNB_uespec_RX; + eNB->proc_tx = proc_tx_full; + if (eNB->node_timing == synch_to_other) { + eNB->tx_fh = tx_fh_if5_mobipass; + eNB->rx_fh = rx_fh_slave; + eNB->fh_asynch = fh_if5_asynch_UL; + + } else { + eNB->tx_fh = tx_fh_if5; + eNB->rx_fh = rx_fh_if5; + eNB->fh_asynch = NULL; + } + + eNB->start_rf = NULL; + eNB->start_if = start_if; + eNB->rfdevice.host_type = BBU_HOST; + + eNB->ifdevice.host_type = BBU_HOST; + + ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], eNB->eth_params); + printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id); + if (ret<0) { + printf("Exiting, cannot initialize transport protocol\n"); + exit(-1); + } + break; + case NGFI_RCC_IF4p5: + eNB->do_precoding = 0; + eNB->do_prach = do_prach; + eNB->fep = NULL; + 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->proc_uespec_rx = phy_procedures_eNB_uespec_RX; + eNB->proc_tx = proc_tx_high; + eNB->tx_fh = tx_fh_if4p5; + eNB->rx_fh = rx_fh_if4p5; + eNB->start_rf = NULL; + eNB->start_if = start_if; + eNB->fh_asynch = (eNB->node_timing == synch_to_other) ? fh_if4p5_asynch_UL : NULL; + eNB->rfdevice.host_type = BBU_HOST; + eNB->ifdevice.host_type = BBU_HOST; + ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], eNB->eth_params); + printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id); + if (ret<0) { + printf("Exiting, cannot initialize transport protocol\n"); + exit(-1); + } + malloc_IF4p5_buffer(eNB); + + break; + case NGFI_RAU_IF4p5: + eNB->do_precoding = 0; + eNB->do_prach = do_prach; + eNB->fep = NULL; + + 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->proc_uespec_rx = phy_procedures_eNB_uespec_RX; + eNB->proc_tx = proc_tx_high; + eNB->tx_fh = tx_fh_if4p5; + eNB->rx_fh = rx_fh_if4p5; + eNB->fh_asynch = (eNB->node_timing == synch_to_other) ? fh_if4p5_asynch_UL : NULL; + eNB->start_rf = NULL; + eNB->start_if = start_if; + + eNB->rfdevice.host_type = BBU_HOST; + eNB->ifdevice.host_type = BBU_HOST; + ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], eNB->eth_params); + printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id); + if (ret<0) { + printf("Exiting, cannot initialize transport protocol\n"); + exit(-1); + } + break; + malloc_IF4p5_buffer(eNB); + + } } - else { - eNB->tx_fh = tx_fh_if5; - eNB->rx_fh = rx_fh_if5; - eNB->fh_asynch = NULL; - } - - eNB->start_rf = NULL; - eNB->start_if = start_if; - eNB->rfdevice.host_type = BBU_HOST; - eNB->ifdevice.host_type = BBU_HOST; - - ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id)); - printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id); - if (ret<0) { - printf("Exiting, cannot initialize transport protocol\n"); - exit(-1); - } - break; - case NGFI_RCC_IF4p5: - eNB->do_precoding = 0; - eNB->do_prach = do_prach; - eNB->fep = NULL; - 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->proc_uespec_rx = phy_procedures_eNB_uespec_RX; - eNB->proc_tx = proc_tx_high; - eNB->tx_fh = tx_fh_if4p5; - eNB->rx_fh = rx_fh_if4p5; - eNB->start_rf = NULL; - eNB->start_if = start_if; - eNB->fh_asynch = (eNB->node_timing == synch_to_other) ? fh_if4p5_asynch_UL : NULL; - eNB->rfdevice.host_type = BBU_HOST; - eNB->ifdevice.host_type = BBU_HOST; - ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id)); - printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id); - if (ret<0) { - printf("Exiting, cannot initialize transport protocol\n"); - exit(-1); + if (setup_eNB_buffers(PHY_vars_eNB_g[inst],&openair0_cfg[CC_id])!=0) { + printf("Exiting, cannot initialize eNodeB Buffers\n"); + exit(-1); } - malloc_IF4p5_buffer(eNB); - - break; - case NGFI_RAU_IF4p5: - eNB->do_precoding = 0; - eNB->do_prach = do_prach; - eNB->fep = NULL; - - 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->proc_uespec_rx = phy_procedures_eNB_uespec_RX; - eNB->proc_tx = proc_tx_high; - eNB->tx_fh = tx_fh_if4p5; - eNB->rx_fh = rx_fh_if4p5; - eNB->fh_asynch = (eNB->node_timing == synch_to_other) ? fh_if4p5_asynch_UL : NULL; - eNB->start_rf = NULL; - eNB->start_if = start_if; - - eNB->rfdevice.host_type = BBU_HOST; - eNB->ifdevice.host_type = BBU_HOST; - ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id)); - printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id); - if (ret<0) { - printf("Exiting, cannot initialize transport protocol\n"); - exit(-1); - } - break; - malloc_IF4p5_buffer(eNB); - - } - } - if (setup_eNB_buffers(PHY_vars_eNB_g[inst],&openair0_cfg[CC_id])!=0) { - printf("Exiting, cannot initialize eNodeB Buffers\n"); - exit(-1); + init_eNB_proc(inst); } - init_eNB_proc(inst); - } + sleep(1); + LOG_D(HW,"[lte-softmodem.c] eNB threads created\n"); - sleep(1); - LOG_D(HW,"[lte-softmodem.c] eNB threads created\n"); - } void stop_eNB(int nb_inst) { - for (int inst=0;inst<nb_inst;inst++) { - printf("Killing eNB %d processing threads\n",inst); - kill_eNB_proc(inst); - } + for (int inst=0; inst<nb_inst; inst++) { + printf("Killing eNB %d processing threads\n",inst); + kill_eNB_proc(inst); + } } diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 6a2aa28d7a4c19a1c0838a534e9850e2d6c39bdc..0e6bbf5048a4c08abf26abc60c81d73109869c60 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -29,37 +29,13 @@ * \note * \warning */ -#define _GNU_SOURCE -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <sched.h> -#include <linux/sched.h> -#include <signal.h> -#include <execinfo.h> -#include <getopt.h> -#include <sys/sysinfo.h> + +#include "lte-softmodem.h" #include "T.h" #include "rt_wrapper.h" -#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all - -#include "assertions.h" -#include "msc.h" - -#include "PHY/types.h" - -#include "PHY/defs.h" -#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all -//#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all - -#include "../../ARCH/COMMON/common_lib.h" #include "../../ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all @@ -94,34 +70,13 @@ unsigned short config_frames[4] = {2,9,11,13}; #endif #if defined(ENABLE_ITTI) -# include "intertask_interface_init.h" -# include "create_tasks.h" -# if defined(ENABLE_USE_MME) -# include "s1ap_eNB.h" -#ifdef PDCP_USE_NETLINK -# include "SIMULATION/ETH_TRANSPORT/proto.h" -extern int netlink_init(void); -#endif -# endif +#include "intertask_interface_init.h" +#include "create_tasks.h" #endif #ifdef XFORMS #include "PHY/TOOLS/lte_phy_scope.h" #include "stats.h" -#endif - -// In lte-enb.c -extern int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_cfg); -extern void init_eNB(eNB_func_t *, eNB_timing_t *,int,eth_params_t *,int,int); -extern void stop_eNB(int); -extern void kill_eNB_proc(void); - -// In lte-ue.c -extern int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg); -extern void fill_ue_band_info(void); -extern void init_UE(int); - -#ifdef XFORMS // current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) // at eNB 0, an UL scope for every UE FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX]; @@ -129,40 +84,24 @@ FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; FD_stats_form *form_stats=NULL,*form_stats_l2=NULL; char title[255]; unsigned char scope_enb_num_ue = 2; +static pthread_t forms_thread; //xforms #endif //XFORMS - - - - - pthread_cond_t sync_cond; pthread_mutex_t sync_mutex; int sync_var=-1; //!< protected by mutex \ref sync_mutex. - - - - -#ifdef XFORMS -static pthread_t forms_thread; //xforms -#endif - uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] - #if defined(ENABLE_ITTI) volatile int start_eNB = 0; volatile int start_UE = 0; #endif volatile int oai_exit = 0; - - static clock_source_t clock_source = internal; - -static wait_for_sync = 0; +static int wait_for_sync = 0; static char UE_flag=0; unsigned int mmapped_dma=0; @@ -209,7 +148,6 @@ int chain_offset=0; int phy_test = 0; uint8_t usim_test = 0; - char ref[128] = "internal"; char channels[128] = "0"; @@ -223,7 +161,6 @@ int otg_enabled; #endif //int number_of_cards = 1; - static LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; eNB_func_t node_function[MAX_NUM_CCs]; eNB_timing_t node_timing[MAX_NUM_CCs]; @@ -235,9 +172,6 @@ uint32_t timing_advance = 0; uint8_t exit_missed_slots=1; uint64_t num_missed_slots=0; // counter for the number of missed slots - -extern void reset_opp_meas(void); -extern void print_opp_meas(void); int transmission_mode=1; int16_t glog_level = LOG_INFO; @@ -268,12 +202,9 @@ int16_t osa_log_level = LOG_INFO; int16_t osa_log_verbosity = LOG_MED; #endif - - char *rrh_UE_ip = "127.0.0.1"; int rrh_UE_port = 51000; - /* flag set by eNB conf file to specify if the radio head is local or remote (default option is local) */ uint8_t local_remote_radio = BBU_LOCAL_RADIO_HEAD; /* struct for ethernet specific parameters given in eNB conf file */ @@ -285,76 +216,77 @@ double cpuf; char uecap_xer[1024],uecap_xer_in=0; - +int oaisim_flag=0; +threads_t threads= {-1,-1,-1}; /*---------------------BMC: timespec helpers -----------------------------*/ struct timespec min_diff_time = { .tv_sec = 0, .tv_nsec = 0 }; struct timespec max_diff_time = { .tv_sec = 0, .tv_nsec = 0 }; -struct timespec clock_difftime(struct timespec start, struct timespec end) -{ - struct timespec temp; - if ((end.tv_nsec-start.tv_nsec)<0) { - temp.tv_sec = end.tv_sec-start.tv_sec-1; - temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec; - } else { - temp.tv_sec = end.tv_sec-start.tv_sec; - temp.tv_nsec = end.tv_nsec-start.tv_nsec; - } - return temp; +struct timespec clock_difftime(struct timespec start, struct timespec end) { + struct timespec temp; + if ((end.tv_nsec-start.tv_nsec)<0) { + temp.tv_sec = end.tv_sec-start.tv_sec-1; + temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec; + } else { + temp.tv_sec = end.tv_sec-start.tv_sec; + temp.tv_nsec = end.tv_nsec-start.tv_nsec; + } + return temp; } -void print_difftimes(void) -{ +void print_difftimes(void) { #ifdef DEBUG - printf("difftimes min = %lu ns ; max = %lu ns\n", min_diff_time.tv_nsec, max_diff_time.tv_nsec); + printf("difftimes min = %lu ns ; max = %lu ns\n", min_diff_time.tv_nsec, max_diff_time.tv_nsec); #else - LOG_I(HW,"difftimes min = %lu ns ; max = %lu ns\n", min_diff_time.tv_nsec, max_diff_time.tv_nsec); + LOG_I(HW,"difftimes min = %lu ns ; max = %lu ns\n", min_diff_time.tv_nsec, max_diff_time.tv_nsec); #endif } -void update_difftimes(struct timespec start, struct timespec end) -{ - struct timespec diff_time = { .tv_sec = 0, .tv_nsec = 0 }; - int changed = 0; - diff_time = clock_difftime(start, end); - if ((min_diff_time.tv_nsec == 0) || (diff_time.tv_nsec < min_diff_time.tv_nsec)) { min_diff_time.tv_nsec = diff_time.tv_nsec; changed = 1; } - if ((max_diff_time.tv_nsec == 0) || (diff_time.tv_nsec > max_diff_time.tv_nsec)) { max_diff_time.tv_nsec = diff_time.tv_nsec; changed = 1; } +void update_difftimes(struct timespec start, struct timespec end) { + struct timespec diff_time = { .tv_sec = 0, .tv_nsec = 0 }; + int changed = 0; + diff_time = clock_difftime(start, end); + if ((min_diff_time.tv_nsec == 0) || (diff_time.tv_nsec < min_diff_time.tv_nsec)) { + min_diff_time.tv_nsec = diff_time.tv_nsec; + changed = 1; + } + if ((max_diff_time.tv_nsec == 0) || (diff_time.tv_nsec > max_diff_time.tv_nsec)) { + max_diff_time.tv_nsec = diff_time.tv_nsec; + changed = 1; + } #if 1 - if (changed) print_difftimes(); + if (changed) print_difftimes(); #endif } /*------------------------------------------------------------------------*/ -unsigned int build_rflocal(int txi, int txq, int rxi, int rxq) -{ - return (txi + (txq<<6) + (rxi<<12) + (rxq<<18)); +unsigned int build_rflocal(int txi, int txq, int rxi, int rxq) { + return (txi + (txq<<6) + (rxi<<12) + (rxq<<18)); } -unsigned int build_rfdc(int dcoff_i_rxfe, int dcoff_q_rxfe) -{ - return (dcoff_i_rxfe + (dcoff_q_rxfe<<8)); +unsigned int build_rfdc(int dcoff_i_rxfe, int dcoff_q_rxfe) { + return (dcoff_i_rxfe + (dcoff_q_rxfe<<8)); } #if !defined(ENABLE_ITTI) -void signal_handler(int sig) -{ - void *array[10]; - size_t size; - - if (sig==SIGSEGV) { - // get void*'s for all entries on the stack - size = backtrace(array, 10); - - // print out all the frames to stderr - fprintf(stderr, "Error: signal %d:\n", sig); - backtrace_symbols_fd(array, size, 2); - exit(-1); - } else { - printf("trying to exit gracefully...\n"); - oai_exit = 1; - } +void signal_handler(int sig) { + void *array[10]; + size_t size; + + if (sig==SIGSEGV) { + // get void*'s for all entries on the stack + size = backtrace(array, 10); + + // print out all the frames to stderr + fprintf(stderr, "Error: signal %d:\n", sig); + backtrace_symbols_fd(array, size, 2); + exit(-1); + } else { + printf("trying to exit gracefully...\n"); + oai_exit = 1; + } } #endif #define KNRM "\x1B[0m" @@ -364,81 +296,79 @@ void signal_handler(int sig) #define RESET "\033[0m" void help (void) { - printf (KGRN "Usage:\n"); - printf(" sudo -E lte-softmodem [options]\n"); - printf(" sudo -E ./lte-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.exmimo2.openEPC.conf -S -V -m 26 -t 16 -x 1 --ulsch-max-errors 100 -W\n\n"); - printf("Options:\n"); - printf(" --rf-config-file Configuration file for front-end (e.g. LMS7002M)\n"); - printf(" --ulsch-max-errors set the max ULSCH erros\n"); - printf(" --calib-ue-rx set UE RX calibration\n"); - printf(" --calib-ue-rx-med \n"); - printf(" --calib-ue-rxbyp\n"); - printf(" --debug-ue-prach run normal prach power ramping, but don't continue random-access\n"); - printf(" --calib-prach-tx run normal prach with maximum power, but don't continue random-access\n"); - printf(" --no-L2-connect bypass L2 and upper layers\n"); - printf(" --ue-rxgain set UE RX gain\n"); - printf(" --ue-rxgain-off external UE amplifier offset\n"); - printf(" --ue-txgain set UE TX gain\n"); - printf(" --ue-scan_carrier set UE to scan around carrier\n"); - printf(" --loop-memory get softmodem (UE) to loop through memory instead of acquiring from HW\n"); - printf(" --mmapped-dma sets flag for improved EXMIMO UE performance\n"); - printf(" --external-clock tells hardware to use an external clock reference\n"); - printf(" --usim-test use XOR autentication algo in case of test usim mode\n"); - printf(" --single-thread-disable. Disables single-thread mode in lte-softmodem\n"); - printf(" -C Set the downlink frequency for all component carriers\n"); - printf(" -d Enable soft scope and L1 and L2 stats (Xforms)\n"); - printf(" -F Calibrate the EXMIMO borad, available files: exmimo2_2arxg.lime exmimo2_2brxg.lime \n"); - printf(" -g Set the global log level, valide options: (9:trace, 8/7:debug, 6:info, 4:warn, 3:error)\n"); - printf(" -G Set the global log verbosity \n"); - printf(" -h provides this help message!\n"); - printf(" -K Generate ITTI analyzser logs (similar to wireshark logs but with more details)\n"); - printf(" -m Set the maximum downlink MCS\n"); - printf(" -O eNB configuration file (located in targets/PROJECTS/GENERIC-LTE-EPC/CONF\n"); - printf(" -q Enable processing timing measurement of lte softmodem on per subframe basis \n"); - printf(" -r Set the PRB, valid values: 6, 25, 50, 100 \n"); - printf(" -S Skip the missed slots/subframes \n"); - printf(" -t Set the maximum uplink MCS\n"); - printf(" -T Set hardware to TDD mode (default: FDD). Used only with -U (otherwise set in config file).\n"); - printf(" -U Set the lte softmodem as a UE\n"); - printf(" -W Enable L2 wireshark messages on localhost \n"); - printf(" -V Enable VCD (generated file will be located atopenair_dump_eNB.vcd, read it with target/RT/USER/eNB.gtkw\n"); - printf(" -x Set the transmission mode, valid options: 1 \n"); - printf(" -E Apply three-quarter of sampling frequency, 23.04 Msps to reduce the data rate on USB/PCIe transfers (only valid for 20 MHz)\n"); + printf (KGRN "Usage:\n"); + printf(" sudo -E lte-softmodem [options]\n"); + printf(" sudo -E ./lte-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.exmimo2.openEPC.conf -S -V -m 26 -t 16 -x 1 --ulsch-max-errors 100 -W\n\n"); + printf("Options:\n"); + printf(" --rf-config-file Configuration file for front-end (e.g. LMS7002M)\n"); + printf(" --ulsch-max-errors set the max ULSCH erros\n"); + printf(" --calib-ue-rx set UE RX calibration\n"); + printf(" --calib-ue-rx-med \n"); + printf(" --calib-ue-rxbyp\n"); + printf(" --debug-ue-prach run normal prach power ramping, but don't continue random-access\n"); + printf(" --calib-prach-tx run normal prach with maximum power, but don't continue random-access\n"); + printf(" --no-L2-connect bypass L2 and upper layers\n"); + printf(" --ue-rxgain set UE RX gain\n"); + printf(" --ue-rxgain-off external UE amplifier offset\n"); + printf(" --ue-txgain set UE TX gain\n"); + printf(" --ue-scan_carrier set UE to scan around carrier\n"); + printf(" --loop-memory get softmodem (UE) to loop through memory instead of acquiring from HW\n"); + printf(" --mmapped-dma sets flag for improved EXMIMO UE performance\n"); + printf(" --external-clock tells hardware to use an external clock reference\n"); + printf(" --usim-test use XOR autentication algo in case of test usim mode\n"); + printf(" --single-thread-disable. Disables single-thread mode in lte-softmodem\n"); + printf(" -C Set the downlink frequency for all component carriers\n"); + printf(" -d Enable soft scope and L1 and L2 stats (Xforms)\n"); + printf(" -F Calibrate the EXMIMO borad, available files: exmimo2_2arxg.lime exmimo2_2brxg.lime \n"); + printf(" -g Set the global log level, valide options: (9:trace, 8/7:debug, 6:info, 4:warn, 3:error)\n"); + printf(" -G Set the global log verbosity \n"); + printf(" -h provides this help message!\n"); + printf(" -K Generate ITTI analyzser logs (similar to wireshark logs but with more details)\n"); + printf(" -m Set the maximum downlink MCS\n"); + printf(" -O eNB configuration file (located in targets/PROJECTS/GENERIC-LTE-EPC/CONF\n"); + printf(" -q Enable processing timing measurement of lte softmodem on per subframe basis \n"); + printf(" -r Set the PRB, valid values: 6, 25, 50, 100 \n"); + printf(" -S Skip the missed slots/subframes \n"); + printf(" -t Set the maximum uplink MCS\n"); + printf(" -T Set hardware to TDD mode (default: FDD). Used only with -U (otherwise set in config file).\n"); + printf(" -U Set the lte softmodem as a UE\n"); + printf(" -W Enable L2 wireshark messages on localhost \n"); + printf(" -V Enable VCD (generated file will be located atopenair_dump_eNB.vcd, read it with target/RT/USER/eNB.gtkw\n"); + printf(" -x Set the transmission mode, valid options: 1 \n"); + printf(" -E Apply three-quarter of sampling frequency, 23.04 Msps to reduce the data rate on USB/PCIe transfers (only valid for 20 MHz)\n"); #if T_TRACER - printf(" --T_port [port] use given port\n"); - printf(" --T_nowait don't wait for tracer, start immediately\n"); - printf(" --T_dont_fork to ease debugging with gdb\n"); + printf(" --T_port [port] use given port\n"); + printf(" --T_nowait don't wait for tracer, start immediately\n"); + printf(" --T_dont_fork to ease debugging with gdb\n"); #endif - printf(RESET); - fflush(stdout); + printf(RESET); + fflush(stdout); } -void exit_fun(const char* s) -{ - int CC_id; - - if (s != NULL) { - printf("%s %s() Exiting OAI softmodem: %s\n",__FILE__, __FUNCTION__, s); - } +void exit_fun(const char* s) { + int CC_id; - oai_exit = 1; - - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - if (UE_flag == 0) { - if (PHY_vars_eNB_g[0][CC_id]->rfdevice.trx_end_func) - PHY_vars_eNB_g[0][CC_id]->rfdevice.trx_end_func(&PHY_vars_eNB_g[0][CC_id]->rfdevice); - if (PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_end_func) - PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_end_func(&PHY_vars_eNB_g[0][CC_id]->ifdevice); + if (s != NULL) { + printf("%s %s() Exiting OAI softmodem: %s\n",__FILE__, __FUNCTION__, s); } - else { - if (PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func) - PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][CC_id]->rfdevice); + + oai_exit = 1; + + for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + if (UE_flag == 0) { + if (PHY_vars_eNB_g[0][CC_id]->rfdevice.trx_end_func) + PHY_vars_eNB_g[0][CC_id]->rfdevice.trx_end_func(&PHY_vars_eNB_g[0][CC_id]->rfdevice); + if (PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_end_func) + PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_end_func(&PHY_vars_eNB_g[0][CC_id]->ifdevice); + } else { + if (PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func) + PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][CC_id]->rfdevice); + } } - } #if defined(ENABLE_ITTI) - sleep(1); //allow lte-softmodem threads to exit first - itti_terminate_tasks (TASK_UNKNOWN); + sleep(1); //allow lte-softmodem threads to exit first + itti_terminate_tasks (TASK_UNKNOWN); #endif } @@ -446,131 +376,129 @@ void exit_fun(const char* s) #ifdef XFORMS -void reset_stats(FL_OBJECT *button, long arg) -{ - int i,j,k; - PHY_VARS_eNB *phy_vars_eNB = PHY_vars_eNB_g[0][0]; - - for (i=0; i<NUMBER_OF_UE_MAX; i++) { - for (k=0; k<8; k++) { //harq_processes - for (j=0; j<phy_vars_eNB->dlsch[i][0]->Mlimit; j++) { - phy_vars_eNB->UE_stats[i].dlsch_NAK[k][j]=0; - phy_vars_eNB->UE_stats[i].dlsch_ACK[k][j]=0; - phy_vars_eNB->UE_stats[i].dlsch_trials[k][j]=0; - } - - phy_vars_eNB->UE_stats[i].dlsch_l2_errors[k]=0; - phy_vars_eNB->UE_stats[i].ulsch_errors[k]=0; - phy_vars_eNB->UE_stats[i].ulsch_consecutive_errors=0; - - for (j=0; j<phy_vars_eNB->ulsch[i]->Mlimit; j++) { - phy_vars_eNB->UE_stats[i].ulsch_decoding_attempts[k][j]=0; - phy_vars_eNB->UE_stats[i].ulsch_decoding_attempts_last[k][j]=0; - phy_vars_eNB->UE_stats[i].ulsch_round_errors[k][j]=0; - phy_vars_eNB->UE_stats[i].ulsch_round_fer[k][j]=0; - } - } +void reset_stats(FL_OBJECT *button, long arg) { + int i,j,k; + PHY_VARS_eNB *phy_vars_eNB = PHY_vars_eNB_g[0][0]; + + for (i=0; i<NUMBER_OF_UE_MAX; i++) { + for (k=0; k<8; k++) { //harq_processes + for (j=0; j<phy_vars_eNB->dlsch[i][0]->Mlimit; j++) { + phy_vars_eNB->UE_stats[i].dlsch_NAK[k][j]=0; + phy_vars_eNB->UE_stats[i].dlsch_ACK[k][j]=0; + phy_vars_eNB->UE_stats[i].dlsch_trials[k][j]=0; + } + + phy_vars_eNB->UE_stats[i].dlsch_l2_errors[k]=0; + phy_vars_eNB->UE_stats[i].ulsch_errors[k]=0; + phy_vars_eNB->UE_stats[i].ulsch_consecutive_errors=0; + + for (j=0; j<phy_vars_eNB->ulsch[i]->Mlimit; j++) { + phy_vars_eNB->UE_stats[i].ulsch_decoding_attempts[k][j]=0; + phy_vars_eNB->UE_stats[i].ulsch_decoding_attempts_last[k][j]=0; + phy_vars_eNB->UE_stats[i].ulsch_round_errors[k][j]=0; + phy_vars_eNB->UE_stats[i].ulsch_round_fer[k][j]=0; + } + } - phy_vars_eNB->UE_stats[i].dlsch_sliding_cnt=0; - phy_vars_eNB->UE_stats[i].dlsch_NAK_round0=0; - phy_vars_eNB->UE_stats[i].dlsch_mcs_offset=0; - } + phy_vars_eNB->UE_stats[i].dlsch_sliding_cnt=0; + phy_vars_eNB->UE_stats[i].dlsch_NAK_round0=0; + phy_vars_eNB->UE_stats[i].dlsch_mcs_offset=0; + } } -static void *scope_thread(void *arg) -{ - char stats_buffer[16384]; +static void *scope_thread(void *arg) { + char stats_buffer[16384]; # ifdef ENABLE_XFORMS_WRITE_STATS - FILE *UE_stats, *eNB_stats; + FILE *UE_stats, *eNB_stats; # endif - int len = 0; - struct sched_param sched_param; - int UE_id, CC_id; - int ue_cnt=0; + int len = 0; + struct sched_param sched_param; + int UE_id, CC_id; + int ue_cnt=0; - sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1; - sched_setscheduler(0, SCHED_FIFO,&sched_param); + sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1; + sched_setscheduler(0, SCHED_FIFO,&sched_param); - printf("Scope thread has priority %d\n",sched_param.sched_priority); + printf("Scope thread has priority %d\n",sched_param.sched_priority); # ifdef ENABLE_XFORMS_WRITE_STATS - if (UE_flag==1) - UE_stats = fopen("UE_stats.txt", "w"); - else - eNB_stats = fopen("eNB_stats.txt", "w"); + if (UE_flag==1) + UE_stats = fopen("UE_stats.txt", "w"); + else + eNB_stats = fopen("eNB_stats.txt", "w"); #endif - while (!oai_exit) { - if (UE_flag==1) { - len = dump_ue_stats (PHY_vars_UE_g[0][0], &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0],stats_buffer, 0, mode,rx_input_level_dBm); - //fl_set_object_label(form_stats->stats_text, stats_buffer); - fl_clear_browser(form_stats->stats_text); - fl_add_browser_line(form_stats->stats_text, stats_buffer); + while (!oai_exit) { + if (UE_flag==1) { + len = dump_ue_stats (PHY_vars_UE_g[0][0], &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0],stats_buffer, 0, mode,rx_input_level_dBm); + //fl_set_object_label(form_stats->stats_text, stats_buffer); + fl_clear_browser(form_stats->stats_text); + fl_add_browser_line(form_stats->stats_text, stats_buffer); - phy_scope_UE(form_ue[0], - PHY_vars_UE_g[0][0], - 0, - 0,7); + phy_scope_UE(form_ue[0], + PHY_vars_UE_g[0][0], + 0, + 0,7); - } else { - if (PHY_vars_eNB_g[0][0]->mac_enabled==1) { - len = dump_eNB_l2_stats (stats_buffer, 0); - //fl_set_object_label(form_stats_l2->stats_text, stats_buffer); - fl_clear_browser(form_stats_l2->stats_text); - fl_add_browser_line(form_stats_l2->stats_text, stats_buffer); - } - len = dump_eNB_stats (PHY_vars_eNB_g[0][0], stats_buffer, 0); - - if (MAX_NUM_CCs>1) - len += dump_eNB_stats (PHY_vars_eNB_g[0][1], &stats_buffer[len], 0); - - //fl_set_object_label(form_stats->stats_text, stats_buffer); - fl_clear_browser(form_stats->stats_text); - fl_add_browser_line(form_stats->stats_text, stats_buffer); - - ue_cnt=0; - for(UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - // if ((PHY_vars_eNB_g[0][CC_id]->dlsch[UE_id][0]->rnti>0) && (ue_cnt<scope_enb_num_ue)) { - if ((ue_cnt<scope_enb_num_ue)) { - phy_scope_eNB(form_enb[CC_id][ue_cnt], - PHY_vars_eNB_g[0][CC_id], - UE_id); - ue_cnt++; - } - } - } + } else { + if (PHY_vars_eNB_g[0][0]->mac_enabled==1) { + len = dump_eNB_l2_stats (stats_buffer, 0); + //fl_set_object_label(form_stats_l2->stats_text, stats_buffer); + fl_clear_browser(form_stats_l2->stats_text); + fl_add_browser_line(form_stats_l2->stats_text, stats_buffer); + } + len = dump_eNB_stats (PHY_vars_eNB_g[0][0], stats_buffer, 0); + + if (MAX_NUM_CCs>1) + len += dump_eNB_stats (PHY_vars_eNB_g[0][1], &stats_buffer[len], 0); + + //fl_set_object_label(form_stats->stats_text, stats_buffer); + fl_clear_browser(form_stats->stats_text); + fl_add_browser_line(form_stats->stats_text, stats_buffer); + + ue_cnt=0; + for(UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { + for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + // if ((PHY_vars_eNB_g[0][CC_id]->dlsch[UE_id][0]->rnti>0) && (ue_cnt<scope_enb_num_ue)) { + if ((ue_cnt<scope_enb_num_ue)) { + phy_scope_eNB(form_enb[CC_id][ue_cnt], + PHY_vars_eNB_g[0][CC_id], + UE_id); + ue_cnt++; + } + } + } - } + } - //printf("doing forms\n"); - //usleep(100000); // 100 ms - sleep(1); - } + //printf("doing forms\n"); + //usleep(100000); // 100 ms + sleep(1); + } - // printf("%s",stats_buffer); + // printf("%s",stats_buffer); # ifdef ENABLE_XFORMS_WRITE_STATS - if (UE_flag==1) { - if (UE_stats) { - rewind (UE_stats); - fwrite (stats_buffer, 1, len, UE_stats); - fclose (UE_stats); - } - } else { - if (eNB_stats) { - rewind (eNB_stats); - fwrite (stats_buffer, 1, len, eNB_stats); - fclose (eNB_stats); + if (UE_flag==1) { + if (UE_stats) { + rewind (UE_stats); + fwrite (stats_buffer, 1, len, UE_stats); + fclose (UE_stats); + } + } else { + if (eNB_stats) { + rewind (eNB_stats); + fwrite (stats_buffer, 1, len, eNB_stats); + fclose (eNB_stats); + } } - } # endif - pthread_exit((void*)arg); + pthread_exit((void*)arg); } #endif @@ -578,656 +506,667 @@ static void *scope_thread(void *arg) #if defined(ENABLE_ITTI) -void *l2l1_task(void *arg) -{ - MessageDef *message_p = NULL; - int result; +void *l2l1_task(void *arg) { + MessageDef *message_p = NULL; + int result; - itti_set_task_real_time(TASK_L2L1); - itti_mark_task_ready(TASK_L2L1); + itti_set_task_real_time(TASK_L2L1); + itti_mark_task_ready(TASK_L2L1); + + if (UE_flag == 0) { + /* Wait for the initialize message */ + printf("Wait for the ITTI initialize message\n"); + do { + if (message_p != NULL) { + result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + } + + itti_receive_msg (TASK_L2L1, &message_p); + + switch (ITTI_MSG_ID(message_p)) { + case INITIALIZE_MESSAGE: + /* Start eNB thread */ + LOG_D(EMU, "L2L1 TASK received %s\n", ITTI_MSG_NAME(message_p)); + start_eNB = 1; + break; + + case TERMINATE_MESSAGE: + printf("received terminate message\n"); + oai_exit=1; + itti_exit_task (); + break; + + default: + LOG_E(EMU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p)); + break; + } + } while (ITTI_MSG_ID(message_p) != INITIALIZE_MESSAGE); - if (UE_flag == 0) { - /* Wait for the initialize message */ - printf("Wait for the ITTI initialize message\n"); - do { - if (message_p != NULL) { result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - } - - itti_receive_msg (TASK_L2L1, &message_p); - - switch (ITTI_MSG_ID(message_p)) { - case INITIALIZE_MESSAGE: - /* Start eNB thread */ - LOG_D(EMU, "L2L1 TASK received %s\n", ITTI_MSG_NAME(message_p)); - start_eNB = 1; - break; - - case TERMINATE_MESSAGE: - printf("received terminate message\n"); - oai_exit=1; - itti_exit_task (); - break; - - default: - LOG_E(EMU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p)); - break; - } - } while (ITTI_MSG_ID(message_p) != INITIALIZE_MESSAGE); - - result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - } - - do { - // Wait for a message - itti_receive_msg (TASK_L2L1, &message_p); - - switch (ITTI_MSG_ID(message_p)) { - case TERMINATE_MESSAGE: - oai_exit=1; - itti_exit_task (); - break; - - case ACTIVATE_MESSAGE: - start_UE = 1; - break; - - case DEACTIVATE_MESSAGE: - start_UE = 0; - break; - - case MESSAGE_TEST: - LOG_I(EMU, "Received %s\n", ITTI_MSG_NAME(message_p)); - break; - - default: - LOG_E(EMU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p)); - break; } - result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - } while(!oai_exit); + do { + // Wait for a message + itti_receive_msg (TASK_L2L1, &message_p); + + switch (ITTI_MSG_ID(message_p)) { + case TERMINATE_MESSAGE: + oai_exit=1; + itti_exit_task (); + break; + + case ACTIVATE_MESSAGE: + start_UE = 1; + break; - return NULL; + case DEACTIVATE_MESSAGE: + start_UE = 0; + break; + + case MESSAGE_TEST: + LOG_I(EMU, "Received %s\n", ITTI_MSG_NAME(message_p)); + break; + + default: + LOG_E(EMU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p)); + break; + } + + result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + } while(!oai_exit); + + return NULL; } #endif - -static void get_options (int argc, char **argv) -{ - int c; - // char line[1000]; - // int l; - int k,i;//,j,k; + +static void get_options (int argc, char **argv) { + int c; + // char line[1000]; + // int l; + int k,i;//,j,k; #if defined(OAI_USRP) || defined(CPRIGW) - int clock_src; + int clock_src; #endif - int CC_id; - - - - const Enb_properties_array_t *enb_properties; - - enum long_option_e { - LONG_OPTION_START = 0x100, /* Start after regular single char options */ - LONG_OPTION_RF_CONFIG_FILE, - LONG_OPTION_ULSCH_MAX_CONSECUTIVE_ERRORS, - LONG_OPTION_CALIB_UE_RX, - LONG_OPTION_CALIB_UE_RX_MED, - LONG_OPTION_CALIB_UE_RX_BYP, - LONG_OPTION_DEBUG_UE_PRACH, - LONG_OPTION_NO_L2_CONNECT, - LONG_OPTION_CALIB_PRACH_TX, - LONG_OPTION_RXGAIN, - LONG_OPTION_RXGAINOFF, - LONG_OPTION_TXGAIN, - LONG_OPTION_SCANCARRIER, - LONG_OPTION_MAXPOWER, - LONG_OPTION_DUMP_FRAME, - LONG_OPTION_LOOPMEMORY, - LONG_OPTION_PHYTEST, - LONG_OPTION_USIMTEST, - LONG_OPTION_MMAPPED_DMA, - LONG_OPTION_EXTERNAL_CLOCK, - LONG_OPTION_WAIT_FOR_SYNC, - LONG_OPTION_SINGLE_THREAD_DISABLE, + int CC_id; + + + + const Enb_properties_array_t *enb_properties; + + enum long_option_e { + LONG_OPTION_START = 0x100, /* Start after regular single char options */ + LONG_OPTION_RF_CONFIG_FILE, + LONG_OPTION_ULSCH_MAX_CONSECUTIVE_ERRORS, + LONG_OPTION_CALIB_UE_RX, + LONG_OPTION_CALIB_UE_RX_MED, + LONG_OPTION_CALIB_UE_RX_BYP, + LONG_OPTION_DEBUG_UE_PRACH, + LONG_OPTION_NO_L2_CONNECT, + LONG_OPTION_CALIB_PRACH_TX, + LONG_OPTION_RXGAIN, + LONG_OPTION_RXGAINOFF, + LONG_OPTION_TXGAIN, + LONG_OPTION_SCANCARRIER, + LONG_OPTION_MAXPOWER, + LONG_OPTION_DUMP_FRAME, + LONG_OPTION_LOOPMEMORY, + LONG_OPTION_PHYTEST, + LONG_OPTION_USIMTEST, + LONG_OPTION_MMAPPED_DMA, + LONG_OPTION_EXTERNAL_CLOCK, + LONG_OPTION_WAIT_FOR_SYNC, + LONG_OPTION_SINGLE_THREAD_DISABLE, + LONG_OPTION_THREADIQ, + LONG_OPTION_THREADODDSUBFRAME, + LONG_OPTION_THREADEVENSUBFRAME, #if T_TRACER - LONG_OPTION_T_PORT, - LONG_OPTION_T_NOWAIT, - LONG_OPTION_T_DONT_FORK, + LONG_OPTION_T_PORT, + LONG_OPTION_T_NOWAIT, + LONG_OPTION_T_DONT_FORK, #endif - }; - - static const struct option long_options[] = { - {"rf-config-file",required_argument, NULL, LONG_OPTION_RF_CONFIG_FILE}, - {"ulsch-max-errors",required_argument, NULL, LONG_OPTION_ULSCH_MAX_CONSECUTIVE_ERRORS}, - {"calib-ue-rx", required_argument, NULL, LONG_OPTION_CALIB_UE_RX}, - {"calib-ue-rx-med", required_argument, NULL, LONG_OPTION_CALIB_UE_RX_MED}, - {"calib-ue-rx-byp", required_argument, NULL, LONG_OPTION_CALIB_UE_RX_BYP}, - {"debug-ue-prach", no_argument, NULL, LONG_OPTION_DEBUG_UE_PRACH}, - {"no-L2-connect", no_argument, NULL, LONG_OPTION_NO_L2_CONNECT}, - {"calib-prach-tx", no_argument, NULL, LONG_OPTION_CALIB_PRACH_TX}, - {"ue-rxgain", required_argument, NULL, LONG_OPTION_RXGAIN}, - {"ue-rxgain-off", required_argument, NULL, LONG_OPTION_RXGAINOFF}, - {"ue-txgain", required_argument, NULL, LONG_OPTION_TXGAIN}, - {"ue-scan-carrier", no_argument, NULL, LONG_OPTION_SCANCARRIER}, - {"ue-max-power", required_argument, NULL, LONG_OPTION_MAXPOWER}, - {"ue-dump-frame", no_argument, NULL, LONG_OPTION_DUMP_FRAME}, - {"loop-memory", required_argument, NULL, LONG_OPTION_LOOPMEMORY}, - {"phy-test", no_argument, NULL, LONG_OPTION_PHYTEST}, - {"usim-test", no_argument, NULL, LONG_OPTION_USIMTEST}, - {"mmapped-dma", no_argument, NULL, LONG_OPTION_MMAPPED_DMA}, - {"external-clock", no_argument, NULL, LONG_OPTION_EXTERNAL_CLOCK}, - {"wait-for-sync", no_argument, NULL, LONG_OPTION_WAIT_FOR_SYNC}, - {"single-thread-disable", no_argument, NULL, LONG_OPTION_SINGLE_THREAD_DISABLE}, + }; + + static const struct option long_options[] = { + {"rf-config-file",required_argument, NULL, LONG_OPTION_RF_CONFIG_FILE}, + {"ulsch-max-errors",required_argument, NULL, LONG_OPTION_ULSCH_MAX_CONSECUTIVE_ERRORS}, + {"calib-ue-rx", required_argument, NULL, LONG_OPTION_CALIB_UE_RX}, + {"calib-ue-rx-med", required_argument, NULL, LONG_OPTION_CALIB_UE_RX_MED}, + {"calib-ue-rx-byp", required_argument, NULL, LONG_OPTION_CALIB_UE_RX_BYP}, + {"debug-ue-prach", no_argument, NULL, LONG_OPTION_DEBUG_UE_PRACH}, + {"no-L2-connect", no_argument, NULL, LONG_OPTION_NO_L2_CONNECT}, + {"calib-prach-tx", no_argument, NULL, LONG_OPTION_CALIB_PRACH_TX}, + {"ue-rxgain", required_argument, NULL, LONG_OPTION_RXGAIN}, + {"ue-rxgain-off", required_argument, NULL, LONG_OPTION_RXGAINOFF}, + {"ue-txgain", required_argument, NULL, LONG_OPTION_TXGAIN}, + {"ue-scan-carrier", no_argument, NULL, LONG_OPTION_SCANCARRIER}, + {"ue-max-power", required_argument, NULL, LONG_OPTION_MAXPOWER}, + {"ue-dump-frame", no_argument, NULL, LONG_OPTION_DUMP_FRAME}, + {"loop-memory", required_argument, NULL, LONG_OPTION_LOOPMEMORY}, + {"phy-test", no_argument, NULL, LONG_OPTION_PHYTEST}, + {"usim-test", no_argument, NULL, LONG_OPTION_USIMTEST}, + {"mmapped-dma", no_argument, NULL, LONG_OPTION_MMAPPED_DMA}, + {"external-clock", no_argument, NULL, LONG_OPTION_EXTERNAL_CLOCK}, + {"wait-for-sync", no_argument, NULL, LONG_OPTION_WAIT_FOR_SYNC}, + {"single-thread-disable", no_argument, NULL, LONG_OPTION_SINGLE_THREAD_DISABLE}, + {"threadIQ", required_argument, NULL, LONG_OPTION_THREADIQ}, + {"threadOddSubframe", required_argument, NULL, LONG_OPTION_THREADODDSUBFRAME}, + {"threadEvenSubframe", required_argument, NULL, LONG_OPTION_THREADEVENSUBFRAME}, #if T_TRACER - {"T_port", required_argument, 0, LONG_OPTION_T_PORT}, - {"T_nowait", no_argument, 0, LONG_OPTION_T_NOWAIT}, - {"T_dont_fork", no_argument, 0, LONG_OPTION_T_DONT_FORK}, + {"T_port", required_argument, 0, LONG_OPTION_T_PORT}, + {"T_nowait", no_argument, 0, LONG_OPTION_T_NOWAIT}, + {"T_dont_fork", no_argument, 0, LONG_OPTION_T_DONT_FORK}, #endif - {NULL, 0, NULL, 0} - }; - - while ((c = getopt_long (argc, argv, "A:a:C:dEK:g:F:G:hqO:m:SUVRM:r:P:Ws:t:Tx:",long_options,NULL)) != -1) { - switch (c) { - case LONG_OPTION_RF_CONFIG_FILE: - if ((strcmp("null", optarg) == 0) || (strcmp("NULL", optarg) == 0)) { - printf("no configuration filename is provided\n"); - } - else if (strlen(optarg)<=1024){ - strcpy(rf_config_file,optarg); - }else { - printf("Configuration filename is too long\n"); - exit(-1); - } - break; - case LONG_OPTION_MAXPOWER: - tx_max_power[0]=atoi(optarg); - for (CC_id=1;CC_id<MAX_NUM_CCs;CC_id++) - tx_max_power[CC_id]=tx_max_power[0]; - break; - case LONG_OPTION_ULSCH_MAX_CONSECUTIVE_ERRORS: - ULSCH_max_consecutive_errors = atoi(optarg); - printf("Set ULSCH_max_consecutive_errors = %d\n",ULSCH_max_consecutive_errors); - break; - - case LONG_OPTION_CALIB_UE_RX: - mode = rx_calib_ue; - rx_input_level_dBm = atoi(optarg); - printf("Running with UE calibration on (LNA max), input level %d dBm\n",rx_input_level_dBm); - break; - - case LONG_OPTION_CALIB_UE_RX_MED: - mode = rx_calib_ue_med; - rx_input_level_dBm = atoi(optarg); - printf("Running with UE calibration on (LNA med), input level %d dBm\n",rx_input_level_dBm); - break; - - case LONG_OPTION_CALIB_UE_RX_BYP: - mode = rx_calib_ue_byp; - rx_input_level_dBm = atoi(optarg); - printf("Running with UE calibration on (LNA byp), input level %d dBm\n",rx_input_level_dBm); - break; - - case LONG_OPTION_DEBUG_UE_PRACH: - mode = debug_prach; - break; - - case LONG_OPTION_NO_L2_CONNECT: - mode = no_L2_connect; - break; - - case LONG_OPTION_CALIB_PRACH_TX: - mode = calib_prach_tx; - printf("Setting mode to calib_prach_tx (%d)\n",mode); - break; - - case LONG_OPTION_RXGAIN: - for (i=0; i<4; i++) - rx_gain[0][i] = atof(optarg); - - break; - - case LONG_OPTION_RXGAINOFF: - rx_gain_off = atof(optarg); - break; - - case LONG_OPTION_TXGAIN: - for (i=0; i<4; i++) - tx_gain[0][i] = atof(optarg); - - break; - - case LONG_OPTION_SCANCARRIER: - UE_scan_carrier=1; - - break; - - case LONG_OPTION_LOOPMEMORY: - mode=loop_through_memory; - input_fd = fopen(optarg,"r"); - AssertFatal(input_fd != NULL,"Please provide an input file\n"); - break; - - case LONG_OPTION_DUMP_FRAME: - mode = rx_dump_frame; - break; - - case LONG_OPTION_PHYTEST: - phy_test = 1; - break; - - case LONG_OPTION_USIMTEST: - usim_test = 1; - break; - case LONG_OPTION_MMAPPED_DMA: - mmapped_dma = 1; - break; - - case LONG_OPTION_SINGLE_THREAD_DISABLE: - single_thread_flag = 0; - break; - - case LONG_OPTION_EXTERNAL_CLOCK: - clock_source = external; - break; - - case LONG_OPTION_WAIT_FOR_SYNC: - wait_for_sync = 1; - break; - + {NULL, 0, NULL, 0} + }; + + while ((c = getopt_long (argc, argv, "A:a:C:dEK:g:F:G:hqO:m:SUVRM:r:P:Ws:t:Tx:",long_options,NULL)) != -1) { + switch (c) { + case LONG_OPTION_RF_CONFIG_FILE: + if ((strcmp("null", optarg) == 0) || (strcmp("NULL", optarg) == 0)) { + printf("no configuration filename is provided\n"); + } else if (strlen(optarg)<=1024) { + strcpy(rf_config_file,optarg); + } else { + printf("Configuration filename is too long\n"); + exit(-1); + } + break; + case LONG_OPTION_MAXPOWER: + tx_max_power[0]=atoi(optarg); + for (CC_id=1; CC_id<MAX_NUM_CCs; CC_id++) + tx_max_power[CC_id]=tx_max_power[0]; + break; + case LONG_OPTION_ULSCH_MAX_CONSECUTIVE_ERRORS: + ULSCH_max_consecutive_errors = atoi(optarg); + printf("Set ULSCH_max_consecutive_errors = %d\n",ULSCH_max_consecutive_errors); + break; + + case LONG_OPTION_CALIB_UE_RX: + mode = rx_calib_ue; + rx_input_level_dBm = atoi(optarg); + printf("Running with UE calibration on (LNA max), input level %d dBm\n",rx_input_level_dBm); + break; + + case LONG_OPTION_CALIB_UE_RX_MED: + mode = rx_calib_ue_med; + rx_input_level_dBm = atoi(optarg); + printf("Running with UE calibration on (LNA med), input level %d dBm\n",rx_input_level_dBm); + break; + + case LONG_OPTION_CALIB_UE_RX_BYP: + mode = rx_calib_ue_byp; + rx_input_level_dBm = atoi(optarg); + printf("Running with UE calibration on (LNA byp), input level %d dBm\n",rx_input_level_dBm); + break; + + case LONG_OPTION_DEBUG_UE_PRACH: + mode = debug_prach; + break; + + case LONG_OPTION_NO_L2_CONNECT: + mode = no_L2_connect; + break; + + case LONG_OPTION_CALIB_PRACH_TX: + mode = calib_prach_tx; + printf("Setting mode to calib_prach_tx (%d)\n",mode); + break; + + case LONG_OPTION_RXGAIN: + for (i=0; i<4; i++) + rx_gain[0][i] = atof(optarg); + + break; + + case LONG_OPTION_RXGAINOFF: + rx_gain_off = atof(optarg); + break; + + case LONG_OPTION_TXGAIN: + for (i=0; i<4; i++) + tx_gain[0][i] = atof(optarg); + + break; + + case LONG_OPTION_SCANCARRIER: + UE_scan_carrier=1; + + break; + + case LONG_OPTION_LOOPMEMORY: + mode=loop_through_memory; + input_fd = fopen(optarg,"r"); + AssertFatal(input_fd != NULL,"Please provide an input file\n"); + break; + + case LONG_OPTION_DUMP_FRAME: + mode = rx_dump_frame; + break; + + case LONG_OPTION_PHYTEST: + phy_test = 1; + break; + + case LONG_OPTION_USIMTEST: + usim_test = 1; + break; + case LONG_OPTION_MMAPPED_DMA: + mmapped_dma = 1; + break; + + case LONG_OPTION_SINGLE_THREAD_DISABLE: + single_thread_flag = 0; + break; + + case LONG_OPTION_EXTERNAL_CLOCK: + clock_source = external; + break; + + case LONG_OPTION_WAIT_FOR_SYNC: + wait_for_sync = 1; + break; + case LONG_OPTION_THREADIQ: + threads.iq=atoi(optarg); + break; + case LONG_OPTION_THREADODDSUBFRAME: + threads.odd=atoi(optarg); + break; + case LONG_OPTION_THREADEVENSUBFRAME: + threads.even=atoi(optarg); + break; #if T_TRACER - case LONG_OPTION_T_PORT: { - extern int T_port; - if (optarg == NULL) abort(); /* should not happen */ - T_port = atoi(optarg); - break; - } + case LONG_OPTION_T_PORT: { + extern int T_port; + if (optarg == NULL) abort(); /* should not happen */ + T_port = atoi(optarg); + break; + } - case LONG_OPTION_T_NOWAIT: { - extern int T_wait; - T_wait = 0; - break; - } + case LONG_OPTION_T_NOWAIT: { + extern int T_wait; + T_wait = 0; + break; + } - case LONG_OPTION_T_DONT_FORK: { - extern int T_dont_fork; - T_dont_fork = 1; - break; - } + case LONG_OPTION_T_DONT_FORK: { + extern int T_dont_fork; + T_dont_fork = 1; + break; + } #endif - case 'A': - timing_advance = atoi (optarg); - break; + case 'A': + timing_advance = atoi (optarg); + break; - case 'C': - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - downlink_frequency[CC_id][0] = atof(optarg); // Use float to avoid issue with frequency over 2^31. - downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0]; - downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0]; - downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0]; - printf("Downlink for CC_id %d frequency set to %u\n", CC_id, downlink_frequency[CC_id][0]); - } + case 'C': + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + downlink_frequency[CC_id][0] = atof(optarg); // Use float to avoid issue with frequency over 2^31. + downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0]; + downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0]; + downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0]; + printf("Downlink for CC_id %d frequency set to %u\n", CC_id, downlink_frequency[CC_id][0]); + } - UE_scan=0; + UE_scan=0; - break; + break; - case 'a': - chain_offset = atoi(optarg); - break; + case 'a': + chain_offset = atoi(optarg); + break; - case 'd': + case 'd': #ifdef XFORMS - do_forms=1; - printf("Running with XFORMS!\n"); + do_forms=1; + printf("Running with XFORMS!\n"); #endif - break; - - case 'E': - threequarter_fs=1; - break; + break; - case 'K': + case 'E': + threequarter_fs=1; + break; + + case 'K': #if defined(ENABLE_ITTI) - itti_dump_file = strdup(optarg); + itti_dump_file = strdup(optarg); #else - printf("-K option is disabled when ENABLE_ITTI is not defined\n"); + printf("-K option is disabled when ENABLE_ITTI is not defined\n"); #endif - break; - - case 'O': - conf_config_file_name = optarg; - break; - - case 'U': - UE_flag = 1; - break; - - case 'm': - target_dl_mcs = atoi (optarg); - break; - - case 't': - target_ul_mcs = atoi (optarg); - break; - - case 'W': - opt_enabled=1; - opt_type = OPT_WIRESHARK; - strncpy(in_ip, "127.0.0.1", sizeof(in_ip)); - in_ip[sizeof(in_ip) - 1] = 0; // terminate string - printf("Enabling OPT for wireshark for local interface"); - /* - if (optarg == NULL){ - in_ip[0] =NULL; - printf("Enabling OPT for wireshark for local interface"); - } else { - strncpy(in_ip, optarg, sizeof(in_ip)); - in_ip[sizeof(in_ip) - 1] = 0; // terminate string - printf("Enabling OPT for wireshark with %s \n",in_ip); - } - */ - break; - - case 'P': - opt_type = OPT_PCAP; - opt_enabled=1; - - if (optarg == NULL) { - strncpy(in_path, "/tmp/oai_opt.pcap", sizeof(in_path)); - in_path[sizeof(in_path) - 1] = 0; // terminate string - printf("Enabling OPT for PCAP with the following path /tmp/oai_opt.pcap"); - } else { - strncpy(in_path, optarg, sizeof(in_path)); - in_path[sizeof(in_path) - 1] = 0; // terminate string - printf("Enabling OPT for PCAP with the following file %s \n",in_path); - } - - break; - - case 'V': - ouput_vcd = 1; - break; - - case 'q': - opp_enabled = 1; - break; - - case 'R' : - online_log_messages =1; - break; - - case 'r': - UE_scan = 0; - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - switch(atoi(optarg)) { - case 6: - frame_parms[CC_id]->N_RB_DL=6; - frame_parms[CC_id]->N_RB_UL=6; - break; - - case 25: - frame_parms[CC_id]->N_RB_DL=25; - frame_parms[CC_id]->N_RB_UL=25; - break; - - case 50: - frame_parms[CC_id]->N_RB_DL=50; - frame_parms[CC_id]->N_RB_UL=50; - break; - - case 100: - frame_parms[CC_id]->N_RB_DL=100; - frame_parms[CC_id]->N_RB_UL=100; - break; - - default: - printf("Unknown N_RB_DL %d, switching to 25\n",atoi(optarg)); - break; - } - } - - break; - - case 's': + break; + + case 'O': + conf_config_file_name = optarg; + break; + + case 'U': + UE_flag = 1; + break; + + case 'm': + target_dl_mcs = atoi (optarg); + break; + + case 't': + target_ul_mcs = atoi (optarg); + break; + + case 'W': + opt_enabled=1; + opt_type = OPT_WIRESHARK; + strncpy(in_ip, "127.0.0.1", sizeof(in_ip)); + in_ip[sizeof(in_ip) - 1] = 0; // terminate string + printf("Enabling OPT for wireshark for local interface"); + /* + if (optarg == NULL){ + in_ip[0] =NULL; + printf("Enabling OPT for wireshark for local interface"); + } else { + strncpy(in_ip, optarg, sizeof(in_ip)); + in_ip[sizeof(in_ip) - 1] = 0; // terminate string + printf("Enabling OPT for wireshark with %s \n",in_ip); + } + */ + break; + + case 'P': + opt_type = OPT_PCAP; + opt_enabled=1; + + if (optarg == NULL) { + strncpy(in_path, "/tmp/oai_opt.pcap", sizeof(in_path)); + in_path[sizeof(in_path) - 1] = 0; // terminate string + printf("Enabling OPT for PCAP with the following path /tmp/oai_opt.pcap"); + } else { + strncpy(in_path, optarg, sizeof(in_path)); + in_path[sizeof(in_path) - 1] = 0; // terminate string + printf("Enabling OPT for PCAP with the following file %s \n",in_path); + } + + break; + + case 'V': + ouput_vcd = 1; + break; + + case 'q': + opp_enabled = 1; + break; + + case 'R' : + online_log_messages =1; + break; + + case 'r': + UE_scan = 0; + + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + switch(atoi(optarg)) { + case 6: + frame_parms[CC_id]->N_RB_DL=6; + frame_parms[CC_id]->N_RB_UL=6; + break; + + case 25: + frame_parms[CC_id]->N_RB_DL=25; + frame_parms[CC_id]->N_RB_UL=25; + break; + + case 50: + frame_parms[CC_id]->N_RB_DL=50; + frame_parms[CC_id]->N_RB_UL=50; + break; + + case 100: + frame_parms[CC_id]->N_RB_DL=100; + frame_parms[CC_id]->N_RB_UL=100; + break; + + default: + printf("Unknown N_RB_DL %d, switching to 25\n",atoi(optarg)); + break; + } + } + + break; + + case 's': #if defined(OAI_USRP) || defined(CPRIGW) - clock_src = atoi(optarg); + clock_src = atoi(optarg); - if (clock_src == 0) { - // char ref[128] = "internal"; - //strncpy(uhd_ref, ref, strlen(ref)+1); - } else if (clock_src == 1) { - //char ref[128] = "external"; - //strncpy(uhd_ref, ref, strlen(ref)+1); - } + if (clock_src == 0) { + // char ref[128] = "internal"; + //strncpy(uhd_ref, ref, strlen(ref)+1); + } else if (clock_src == 1) { + //char ref[128] = "external"; + //strncpy(uhd_ref, ref, strlen(ref)+1); + } #else - printf("Note: -s not defined for ExpressMIMO2\n"); + printf("Note: -s not defined for ExpressMIMO2\n"); #endif - break; - - case 'S': - exit_missed_slots=0; - printf("Skip exit for missed slots\n"); - break; - - case 'g': - glog_level=atoi(optarg); // value between 1 - 9 - break; - - case 'F': - break; - - case 'G': - glog_verbosity=atoi(optarg);// value from 0, 0x5, 0x15, 0x35, 0x75 - break; - - case 'x': - printf("Transmission mode should be set in config file now\n"); - exit(-1); - /* - transmission_mode = atoi(optarg); + break; + + case 'S': + exit_missed_slots=0; + printf("Skip exit for missed slots\n"); + break; + + case 'g': + glog_level=atoi(optarg); // value between 1 - 9 + break; + + case 'F': + break; + + case 'G': + glog_verbosity=atoi(optarg);// value from 0, 0x5, 0x15, 0x35, 0x75 + break; + + case 'x': + printf("Transmission mode should be set in config file now\n"); + exit(-1); + /* + transmission_mode = atoi(optarg); + + if (transmission_mode > 7) { + printf("Transmission mode %d not supported for the moment\n",transmission_mode); + exit(-1); + } + */ + break; + + case 'T': + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) + frame_parms[CC_id]->frame_type = TDD; + break; + + case 'h': + help (); + exit (-1); - if (transmission_mode > 7) { - printf("Transmission mode %d not supported for the moment\n",transmission_mode); - exit(-1); - } - */ - break; - - case 'T': - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) - frame_parms[CC_id]->frame_type = TDD; - break; - - case 'h': - help (); - exit (-1); - - default: - help (); - exit (-1); - break; - } - } - - if (UE_flag == 0) - AssertFatal(conf_config_file_name != NULL,"Please provide a configuration file\n"); - - if ((UE_flag == 0) && (conf_config_file_name != NULL)) { - int i,j; - - NB_eNB_INST = 1; - - /* Read eNB configuration file */ - enb_properties = enb_config_init(conf_config_file_name); - - AssertFatal (NB_eNB_INST <= enb_properties->number, - "Number of eNB is greater than eNB defined in configuration file %s (%d/%d)!", - conf_config_file_name, NB_eNB_INST, enb_properties->number); - - /* Update some simulation parameters */ - for (i=0; i < enb_properties->number; i++) { - AssertFatal (MAX_NUM_CCs == enb_properties->properties[i]->nb_cc, - "lte-softmodem compiled with MAX_NUM_CCs=%d, but only %d CCs configured for eNB %d!", - MAX_NUM_CCs, enb_properties->properties[i]->nb_cc, i); - eth_params = (eth_params_t*)malloc(enb_properties->properties[i]->nb_rrh_gw * sizeof(eth_params_t)); - memset(eth_params, 0, enb_properties->properties[i]->nb_rrh_gw * sizeof(eth_params_t)); - - for (j=0; j<enb_properties->properties[i]->nb_rrh_gw; j++) { - - if (enb_properties->properties[i]->rrh_gw_config[j].active == 1 ) { - local_remote_radio = BBU_REMOTE_RADIO_HEAD; - (eth_params+j)->local_if_name = enb_properties->properties[i]->rrh_gw_config[j].rrh_gw_if_name; - (eth_params+j)->my_addr = enb_properties->properties[i]->rrh_gw_config[j].local_address; - (eth_params+j)->my_port = enb_properties->properties[i]->rrh_gw_config[j].local_port; - (eth_params+j)->remote_addr = enb_properties->properties[i]->rrh_gw_config[j].remote_address; - (eth_params+j)->remote_port = enb_properties->properties[i]->rrh_gw_config[j].remote_port; - - if (enb_properties->properties[i]->rrh_gw_config[j].raw == 1) { - (eth_params+j)->transp_preference = ETH_RAW_MODE; - } else if (enb_properties->properties[i]->rrh_gw_config[j].rawif4p5 == 1) { - (eth_params+j)->transp_preference = ETH_RAW_IF4p5_MODE; - } else if (enb_properties->properties[i]->rrh_gw_config[j].udpif4p5 == 1) { - (eth_params+j)->transp_preference = ETH_UDP_IF4p5_MODE; - } else if (enb_properties->properties[i]->rrh_gw_config[j].rawif5_mobipass == 1) { - (eth_params+j)->transp_preference = ETH_RAW_IF5_MOBIPASS; - } else { - (eth_params+j)->transp_preference = ETH_UDP_MODE; - } - - (eth_params+j)->iq_txshift = enb_properties->properties[i]->rrh_gw_config[j].iq_txshift; - (eth_params+j)->tx_sample_advance = enb_properties->properties[i]->rrh_gw_config[j].tx_sample_advance; - (eth_params+j)->tx_scheduling_advance = enb_properties->properties[i]->rrh_gw_config[j].tx_scheduling_advance; - if (enb_properties->properties[i]->rrh_gw_config[j].exmimo == 1) { - (eth_params+j)->rf_preference = EXMIMO_DEV; - } else if (enb_properties->properties[i]->rrh_gw_config[j].usrp_b200 == 1) { - (eth_params+j)->rf_preference = USRP_B200_DEV; - } else if (enb_properties->properties[i]->rrh_gw_config[j].usrp_x300 == 1) { - (eth_params+j)->rf_preference = USRP_X300_DEV; - } else if (enb_properties->properties[i]->rrh_gw_config[j].bladerf == 1) { - (eth_params+j)->rf_preference = BLADERF_DEV; - } else if (enb_properties->properties[i]->rrh_gw_config[j].lmssdr == 1) { - //(eth_params+j)->rf_preference = LMSSDR_DEV; - } else { - (eth_params+j)->rf_preference = 0; - } - } else { - local_remote_radio = BBU_LOCAL_RADIO_HEAD; + default: + help (); + exit (-1); + break; } - - } - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - - - node_function[CC_id] = enb_properties->properties[i]->cc_node_function[CC_id]; - node_timing[CC_id] = enb_properties->properties[i]->cc_node_timing[CC_id]; - node_synch_ref[CC_id] = enb_properties->properties[i]->cc_node_synch_ref[CC_id]; - - frame_parms[CC_id]->frame_type = enb_properties->properties[i]->frame_type[CC_id]; - frame_parms[CC_id]->tdd_config = enb_properties->properties[i]->tdd_config[CC_id]; - frame_parms[CC_id]->tdd_config_S = enb_properties->properties[i]->tdd_config_s[CC_id]; - frame_parms[CC_id]->Ncp = enb_properties->properties[i]->prefix_type[CC_id]; - - //for (j=0; j < enb_properties->properties[i]->nb_cc; j++ ){ - frame_parms[CC_id]->Nid_cell = enb_properties->properties[i]->Nid_cell[CC_id]; - frame_parms[CC_id]->N_RB_DL = enb_properties->properties[i]->N_RB_DL[CC_id]; - frame_parms[CC_id]->N_RB_UL = enb_properties->properties[i]->N_RB_DL[CC_id]; - frame_parms[CC_id]->nb_antennas_tx = enb_properties->properties[i]->nb_antennas_tx[CC_id]; - frame_parms[CC_id]->nb_antenna_ports_eNB = enb_properties->properties[i]->nb_antenna_ports[CC_id]; - frame_parms[CC_id]->nb_antennas_rx = enb_properties->properties[i]->nb_antennas_rx[CC_id]; - - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex = enb_properties->properties[i]->prach_config_index[CC_id]; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset = enb_properties->properties[i]->prach_freq_offset[CC_id]; - - frame_parms[CC_id]->mode1_flag = (frame_parms[CC_id]->nb_antenna_ports_eNB == 1) ? 1 : 0; - frame_parms[CC_id]->threequarter_fs = threequarter_fs; - - //} // j - } - - - init_all_otg(0); - g_otg->seed = 0; - init_seeds(g_otg->seed); - - for (k=0; k<enb_properties->properties[i]->num_otg_elements; k++) { - j=enb_properties->properties[i]->otg_ue_id[k]; // ue_id - g_otg->application_idx[i][j] = 1; - //g_otg->packet_gen_type=SUBSTRACT_STRING; - g_otg->background[i][j][0] =enb_properties->properties[i]->otg_bg_traffic[k]; - g_otg->application_type[i][j][0] =enb_properties->properties[i]->otg_app_type[k];// BCBR; //MCBR, BCBR - - printf("[OTG] configuring traffic type %d for eNB %d UE %d (Background traffic is %s)\n", - g_otg->application_type[i][j][0], i, j,(g_otg->background[i][j][0]==1)?"Enabled":"Disabled"); - } - - init_predef_traffic(enb_properties->properties[i]->num_otg_elements, 1); - - - glog_level = enb_properties->properties[i]->glog_level; - glog_verbosity = enb_properties->properties[i]->glog_verbosity; - hw_log_level = enb_properties->properties[i]->hw_log_level; - hw_log_verbosity = enb_properties->properties[i]->hw_log_verbosity ; - phy_log_level = enb_properties->properties[i]->phy_log_level; - phy_log_verbosity = enb_properties->properties[i]->phy_log_verbosity; - mac_log_level = enb_properties->properties[i]->mac_log_level; - mac_log_verbosity = enb_properties->properties[i]->mac_log_verbosity; - rlc_log_level = enb_properties->properties[i]->rlc_log_level; - rlc_log_verbosity = enb_properties->properties[i]->rlc_log_verbosity; - pdcp_log_level = enb_properties->properties[i]->pdcp_log_level; - pdcp_log_verbosity = enb_properties->properties[i]->pdcp_log_verbosity; - rrc_log_level = enb_properties->properties[i]->rrc_log_level; - rrc_log_verbosity = enb_properties->properties[i]->rrc_log_verbosity; + } + + if (UE_flag == 0) + AssertFatal(conf_config_file_name != NULL,"Please provide a configuration file\n"); + + if ((UE_flag == 0) && (conf_config_file_name != NULL)) { + int i,j; + + NB_eNB_INST = 1; + + /* Read eNB configuration file */ + enb_properties = enb_config_init(conf_config_file_name); + + AssertFatal (NB_eNB_INST <= enb_properties->number, + "Number of eNB is greater than eNB defined in configuration file %s (%d/%d)!", + conf_config_file_name, NB_eNB_INST, enb_properties->number); + + /* Update some simulation parameters */ + for (i=0; i < enb_properties->number; i++) { + AssertFatal (MAX_NUM_CCs == enb_properties->properties[i]->nb_cc, + "lte-softmodem compiled with MAX_NUM_CCs=%d, but only %d CCs configured for eNB %d!", + MAX_NUM_CCs, enb_properties->properties[i]->nb_cc, i); + eth_params = (eth_params_t*)malloc(enb_properties->properties[i]->nb_rrh_gw * sizeof(eth_params_t)); + memset(eth_params, 0, enb_properties->properties[i]->nb_rrh_gw * sizeof(eth_params_t)); + + for (j=0; j<enb_properties->properties[i]->nb_rrh_gw; j++) { + + if (enb_properties->properties[i]->rrh_gw_config[j].active == 1 ) { + local_remote_radio = BBU_REMOTE_RADIO_HEAD; + (eth_params+j)->local_if_name = enb_properties->properties[i]->rrh_gw_config[j].rrh_gw_if_name; + (eth_params+j)->my_addr = enb_properties->properties[i]->rrh_gw_config[j].local_address; + (eth_params+j)->my_port = enb_properties->properties[i]->rrh_gw_config[j].local_port; + (eth_params+j)->remote_addr = enb_properties->properties[i]->rrh_gw_config[j].remote_address; + (eth_params+j)->remote_port = enb_properties->properties[i]->rrh_gw_config[j].remote_port; + + if (enb_properties->properties[i]->rrh_gw_config[j].raw == 1) { + (eth_params+j)->transp_preference = ETH_RAW_MODE; + } else if (enb_properties->properties[i]->rrh_gw_config[j].rawif4p5 == 1) { + (eth_params+j)->transp_preference = ETH_RAW_IF4p5_MODE; + } else if (enb_properties->properties[i]->rrh_gw_config[j].udpif4p5 == 1) { + (eth_params+j)->transp_preference = ETH_UDP_IF4p5_MODE; + } else if (enb_properties->properties[i]->rrh_gw_config[j].rawif5_mobipass == 1) { + (eth_params+j)->transp_preference = ETH_RAW_IF5_MOBIPASS; + } else { + (eth_params+j)->transp_preference = ETH_UDP_MODE; + } + + (eth_params+j)->iq_txshift = enb_properties->properties[i]->rrh_gw_config[j].iq_txshift; + (eth_params+j)->tx_sample_advance = enb_properties->properties[i]->rrh_gw_config[j].tx_sample_advance; + (eth_params+j)->tx_scheduling_advance = enb_properties->properties[i]->rrh_gw_config[j].tx_scheduling_advance; + if (enb_properties->properties[i]->rrh_gw_config[j].exmimo == 1) { + (eth_params+j)->rf_preference = EXMIMO_DEV; + } else if (enb_properties->properties[i]->rrh_gw_config[j].usrp_b200 == 1) { + (eth_params+j)->rf_preference = USRP_B200_DEV; + } else if (enb_properties->properties[i]->rrh_gw_config[j].usrp_x300 == 1) { + (eth_params+j)->rf_preference = USRP_X300_DEV; + } else if (enb_properties->properties[i]->rrh_gw_config[j].bladerf == 1) { + (eth_params+j)->rf_preference = BLADERF_DEV; + } else if (enb_properties->properties[i]->rrh_gw_config[j].lmssdr == 1) { + //(eth_params+j)->rf_preference = LMSSDR_DEV; + } else { + (eth_params+j)->rf_preference = 0; + } + } else { + local_remote_radio = BBU_LOCAL_RADIO_HEAD; + } + + } + + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + + + node_function[CC_id] = enb_properties->properties[i]->cc_node_function[CC_id]; + node_timing[CC_id] = enb_properties->properties[i]->cc_node_timing[CC_id]; + node_synch_ref[CC_id] = enb_properties->properties[i]->cc_node_synch_ref[CC_id]; + + frame_parms[CC_id]->frame_type = enb_properties->properties[i]->frame_type[CC_id]; + frame_parms[CC_id]->tdd_config = enb_properties->properties[i]->tdd_config[CC_id]; + frame_parms[CC_id]->tdd_config_S = enb_properties->properties[i]->tdd_config_s[CC_id]; + frame_parms[CC_id]->Ncp = enb_properties->properties[i]->prefix_type[CC_id]; + + //for (j=0; j < enb_properties->properties[i]->nb_cc; j++ ){ + frame_parms[CC_id]->Nid_cell = enb_properties->properties[i]->Nid_cell[CC_id]; + frame_parms[CC_id]->N_RB_DL = enb_properties->properties[i]->N_RB_DL[CC_id]; + frame_parms[CC_id]->N_RB_UL = enb_properties->properties[i]->N_RB_DL[CC_id]; + frame_parms[CC_id]->nb_antennas_tx = enb_properties->properties[i]->nb_antennas_tx[CC_id]; + frame_parms[CC_id]->nb_antenna_ports_eNB = enb_properties->properties[i]->nb_antenna_ports[CC_id]; + frame_parms[CC_id]->nb_antennas_rx = enb_properties->properties[i]->nb_antennas_rx[CC_id]; + + frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex = enb_properties->properties[i]->prach_config_index[CC_id]; + frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset = enb_properties->properties[i]->prach_freq_offset[CC_id]; + + frame_parms[CC_id]->mode1_flag = (frame_parms[CC_id]->nb_antenna_ports_eNB == 1) ? 1 : 0; + frame_parms[CC_id]->threequarter_fs = threequarter_fs; + + //} // j + } + + + init_all_otg(0); + g_otg->seed = 0; + init_seeds(g_otg->seed); + + for (k=0; k<enb_properties->properties[i]->num_otg_elements; k++) { + j=enb_properties->properties[i]->otg_ue_id[k]; // ue_id + g_otg->application_idx[i][j] = 1; + //g_otg->packet_gen_type=SUBSTRACT_STRING; + g_otg->background[i][j][0] =enb_properties->properties[i]->otg_bg_traffic[k]; + g_otg->application_type[i][j][0] =enb_properties->properties[i]->otg_app_type[k];// BCBR; //MCBR, BCBR + + printf("[OTG] configuring traffic type %d for eNB %d UE %d (Background traffic is %s)\n", + g_otg->application_type[i][j][0], i, j,(g_otg->background[i][j][0]==1)?"Enabled":"Disabled"); + } + + init_predef_traffic(enb_properties->properties[i]->num_otg_elements, 1); + + + glog_level = enb_properties->properties[i]->glog_level; + glog_verbosity = enb_properties->properties[i]->glog_verbosity; + hw_log_level = enb_properties->properties[i]->hw_log_level; + hw_log_verbosity = enb_properties->properties[i]->hw_log_verbosity ; + phy_log_level = enb_properties->properties[i]->phy_log_level; + phy_log_verbosity = enb_properties->properties[i]->phy_log_verbosity; + mac_log_level = enb_properties->properties[i]->mac_log_level; + mac_log_verbosity = enb_properties->properties[i]->mac_log_verbosity; + rlc_log_level = enb_properties->properties[i]->rlc_log_level; + rlc_log_verbosity = enb_properties->properties[i]->rlc_log_verbosity; + pdcp_log_level = enb_properties->properties[i]->pdcp_log_level; + pdcp_log_verbosity = enb_properties->properties[i]->pdcp_log_verbosity; + rrc_log_level = enb_properties->properties[i]->rrc_log_level; + rrc_log_verbosity = enb_properties->properties[i]->rrc_log_verbosity; # if defined(ENABLE_USE_MME) - gtpu_log_level = enb_properties->properties[i]->gtpu_log_level; - gtpu_log_verbosity = enb_properties->properties[i]->gtpu_log_verbosity; - udp_log_level = enb_properties->properties[i]->udp_log_level; - udp_log_verbosity = enb_properties->properties[i]->udp_log_verbosity; + gtpu_log_level = enb_properties->properties[i]->gtpu_log_level; + gtpu_log_verbosity = enb_properties->properties[i]->gtpu_log_verbosity; + udp_log_level = enb_properties->properties[i]->udp_log_level; + udp_log_verbosity = enb_properties->properties[i]->udp_log_verbosity; #endif #if defined (ENABLE_SECURITY) - osa_log_level = enb_properties->properties[i]->osa_log_level; - osa_log_verbosity = enb_properties->properties[i]->osa_log_verbosity; + osa_log_level = enb_properties->properties[i]->osa_log_level; + osa_log_verbosity = enb_properties->properties[i]->osa_log_verbosity; #endif - // adjust the log - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - for (k = 0 ; k < 4; k++) { - downlink_frequency[CC_id][k] = enb_properties->properties[i]->downlink_frequency[CC_id]; - uplink_frequency_offset[CC_id][k] = enb_properties->properties[i]->uplink_frequency_offset[CC_id]; - rx_gain[CC_id][k] = (double)enb_properties->properties[i]->rx_gain[CC_id]; - tx_gain[CC_id][k] = (double)enb_properties->properties[i]->tx_gain[CC_id]; - } + // adjust the log + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + for (k = 0 ; k < 4; k++) { + downlink_frequency[CC_id][k] = enb_properties->properties[i]->downlink_frequency[CC_id]; + uplink_frequency_offset[CC_id][k] = enb_properties->properties[i]->uplink_frequency_offset[CC_id]; + rx_gain[CC_id][k] = (double)enb_properties->properties[i]->rx_gain[CC_id]; + tx_gain[CC_id][k] = (double)enb_properties->properties[i]->tx_gain[CC_id]; + } - printf("Downlink frequency/ uplink offset of CC_id %d set to %ju/%d\n", CC_id, - enb_properties->properties[i]->downlink_frequency[CC_id], - enb_properties->properties[i]->uplink_frequency_offset[CC_id]); + printf("Downlink frequency/ uplink offset of CC_id %d set to %ju/%d\n", CC_id, + enb_properties->properties[i]->downlink_frequency[CC_id], + enb_properties->properties[i]->uplink_frequency_offset[CC_id]); - } // CC_id - }// i + } // CC_id + }// i - //this is needed for phy-test option - transmission_mode = enb_properties->properties[0]->ue_TransmissionMode[0]+1; + //this is needed for phy-test option + transmission_mode = enb_properties->properties[0]->ue_TransmissionMode[0]+1; - } else if (UE_flag == 1) { - if (conf_config_file_name != NULL) { - - // Here the configuration file is the XER encoded UE capabilities - // Read it in and store in asn1c data structures - strcpy(uecap_xer,conf_config_file_name); - uecap_xer_in=1; + } else if (UE_flag == 1) { + if (conf_config_file_name != NULL) { + + // Here the configuration file is the XER encoded UE capabilities + // Read it in and store in asn1c data structures + strcpy(uecap_xer,conf_config_file_name); + uecap_xer_in=1; + } } - } } #if T_TRACER @@ -1239,47 +1178,47 @@ int T_dont_fork = 0; /* default is to fork, see 'T_init' to understand */ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]); void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { - int CC_id; - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - frame_parms[CC_id] = (LTE_DL_FRAME_PARMS*) malloc(sizeof(LTE_DL_FRAME_PARMS)); - /* Set some default values that may be overwritten while reading options */ - frame_parms[CC_id]->frame_type = FDD; - frame_parms[CC_id]->tdd_config = 3; - frame_parms[CC_id]->tdd_config_S = 0; - frame_parms[CC_id]->N_RB_DL = 100; - frame_parms[CC_id]->N_RB_UL = 100; - frame_parms[CC_id]->Ncp = NORMAL; - frame_parms[CC_id]->Ncp_UL = NORMAL; - frame_parms[CC_id]->Nid_cell = 0; - frame_parms[CC_id]->num_MBSFN_config = 0; - frame_parms[CC_id]->nb_antenna_ports_eNB = 1; - frame_parms[CC_id]->nb_antennas_tx = 1; - frame_parms[CC_id]->nb_antennas_rx = 1; - - frame_parms[CC_id]->nushift = 0; - - frame_parms[CC_id]->phich_config_common.phich_resource = oneSixth; - frame_parms[CC_id]->phich_config_common.phich_duration = normal; - // UL RS Config - frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = 0;//n_DMRS1 set to 0 - frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 0; - frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0; - frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0; - - frame_parms[CC_id]->prach_config_common.rootSequenceIndex=22; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=1; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=0; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.highSpeedFlag=0; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset=0; - - downlink_frequency[CC_id][0] = 2680000000; // Use float to avoid issue with frequency over 2^31. - downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0]; - downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0]; - downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0]; - //printf("Downlink for CC_id %d frequency set to %u\n", CC_id, downlink_frequency[CC_id][0]); - - } + int CC_id; + + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + frame_parms[CC_id] = (LTE_DL_FRAME_PARMS*) malloc(sizeof(LTE_DL_FRAME_PARMS)); + /* Set some default values that may be overwritten while reading options */ + frame_parms[CC_id]->frame_type = FDD; + frame_parms[CC_id]->tdd_config = 3; + frame_parms[CC_id]->tdd_config_S = 0; + frame_parms[CC_id]->N_RB_DL = 100; + frame_parms[CC_id]->N_RB_UL = 100; + frame_parms[CC_id]->Ncp = NORMAL; + frame_parms[CC_id]->Ncp_UL = NORMAL; + frame_parms[CC_id]->Nid_cell = 0; + frame_parms[CC_id]->num_MBSFN_config = 0; + frame_parms[CC_id]->nb_antenna_ports_eNB = 1; + frame_parms[CC_id]->nb_antennas_tx = 1; + frame_parms[CC_id]->nb_antennas_rx = 1; + + frame_parms[CC_id]->nushift = 0; + + frame_parms[CC_id]->phich_config_common.phich_resource = oneSixth; + frame_parms[CC_id]->phich_config_common.phich_duration = normal; + // UL RS Config + frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = 0;//n_DMRS1 set to 0 + frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 0; + frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0; + frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0; + + frame_parms[CC_id]->prach_config_common.rootSequenceIndex=22; + frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=1; + frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=0; + frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.highSpeedFlag=0; + frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset=0; + + downlink_frequency[CC_id][0] = 2680000000; // Use float to avoid issue with frequency over 2^31. + downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0]; + downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0]; + downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0]; + //printf("Downlink for CC_id %d frequency set to %u\n", CC_id, downlink_frequency[CC_id][0]); + + } } @@ -1287,726 +1226,713 @@ void init_openair0(void); void init_openair0() { - int card; - int i; - - for (card=0; card<MAX_CARDS; card++) { - - openair0_cfg[card].mmapped_dma=mmapped_dma; - openair0_cfg[card].configFilename = NULL; - - if(frame_parms[0]->N_RB_DL == 100) { - if (frame_parms[0]->threequarter_fs) { - openair0_cfg[card].sample_rate=23.04e6; - openair0_cfg[card].samples_per_frame = 230400; - openair0_cfg[card].tx_bw = 10e6; - openair0_cfg[card].rx_bw = 10e6; - } - else { - openair0_cfg[card].sample_rate=30.72e6; - openair0_cfg[card].samples_per_frame = 307200; - openair0_cfg[card].tx_bw = 10e6; - openair0_cfg[card].rx_bw = 10e6; - } - } else if(frame_parms[0]->N_RB_DL == 50) { - openair0_cfg[card].sample_rate=15.36e6; - openair0_cfg[card].samples_per_frame = 153600; - openair0_cfg[card].tx_bw = 5e6; - openair0_cfg[card].rx_bw = 5e6; - } else if (frame_parms[0]->N_RB_DL == 25) { - openair0_cfg[card].sample_rate=7.68e6; - openair0_cfg[card].samples_per_frame = 76800; - openair0_cfg[card].tx_bw = 2.5e6; - openair0_cfg[card].rx_bw = 2.5e6; - } else if (frame_parms[0]->N_RB_DL == 6) { - openair0_cfg[card].sample_rate=1.92e6; - openair0_cfg[card].samples_per_frame = 19200; - openair0_cfg[card].tx_bw = 1.5e6; - openair0_cfg[card].rx_bw = 1.5e6; - } + int card; + int i; + + for (card=0; card<MAX_CARDS; card++) { + + openair0_cfg[card].mmapped_dma=mmapped_dma; + openair0_cfg[card].configFilename = NULL; + + if(frame_parms[0]->N_RB_DL == 100) { + if (frame_parms[0]->threequarter_fs) { + openair0_cfg[card].sample_rate=23.04e6; + openair0_cfg[card].samples_per_frame = 230400; + openair0_cfg[card].tx_bw = 10e6; + openair0_cfg[card].rx_bw = 10e6; + } else { + openair0_cfg[card].sample_rate=30.72e6; + openair0_cfg[card].samples_per_frame = 307200; + openair0_cfg[card].tx_bw = 10e6; + openair0_cfg[card].rx_bw = 10e6; + } + } else if(frame_parms[0]->N_RB_DL == 50) { + openair0_cfg[card].sample_rate=15.36e6; + openair0_cfg[card].samples_per_frame = 153600; + openair0_cfg[card].tx_bw = 5e6; + openair0_cfg[card].rx_bw = 5e6; + } else if (frame_parms[0]->N_RB_DL == 25) { + openair0_cfg[card].sample_rate=7.68e6; + openair0_cfg[card].samples_per_frame = 76800; + openair0_cfg[card].tx_bw = 2.5e6; + openair0_cfg[card].rx_bw = 2.5e6; + } else if (frame_parms[0]->N_RB_DL == 6) { + openair0_cfg[card].sample_rate=1.92e6; + openair0_cfg[card].samples_per_frame = 19200; + openair0_cfg[card].tx_bw = 1.5e6; + openair0_cfg[card].rx_bw = 1.5e6; + } + + if (frame_parms[0]->frame_type==TDD) + openair0_cfg[card].duplex_mode = duplex_mode_TDD; + else //FDD + openair0_cfg[card].duplex_mode = duplex_mode_FDD; + + + if (local_remote_radio == BBU_REMOTE_RADIO_HEAD) { + openair0_cfg[card].remote_addr = (eth_params+card)->remote_addr; + openair0_cfg[card].remote_port = (eth_params+card)->remote_port; + openair0_cfg[card].my_addr = (eth_params+card)->my_addr; + openair0_cfg[card].my_port = (eth_params+card)->my_port; + } + + printf("HW: Configuring card %d, nb_antennas_tx/rx %d/%d\n",card, + ((UE_flag==0) ? PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx), + ((UE_flag==0) ? PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_rx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx)); + openair0_cfg[card].Mod_id = 0; + + if (UE_flag) { + printf("ETHERNET: Configuring UE ETH for %s:%d\n",rrh_UE_ip,rrh_UE_port); + openair0_cfg[card].remote_addr = &rrh_UE_ip[0]; + openair0_cfg[card].remote_port = rrh_UE_port; + } + + openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL; + + openair0_cfg[card].clock_source = clock_source; + + openair0_cfg[card].tx_num_channels=min(2,((UE_flag==0) ? PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx)); + openair0_cfg[card].rx_num_channels=min(2,((UE_flag==0) ? PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_rx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx)); - if (frame_parms[0]->frame_type==TDD) - openair0_cfg[card].duplex_mode = duplex_mode_TDD; - else //FDD - openair0_cfg[card].duplex_mode = duplex_mode_FDD; - - - if (local_remote_radio == BBU_REMOTE_RADIO_HEAD) { - openair0_cfg[card].remote_addr = (eth_params+card)->remote_addr; - openair0_cfg[card].remote_port = (eth_params+card)->remote_port; - openair0_cfg[card].my_addr = (eth_params+card)->my_addr; - openair0_cfg[card].my_port = (eth_params+card)->my_port; - } - - printf("HW: Configuring card %d, nb_antennas_tx/rx %d/%d\n",card, - ((UE_flag==0) ? PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx), - ((UE_flag==0) ? PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_rx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx)); - openair0_cfg[card].Mod_id = 0; - - if (UE_flag) { - printf("ETHERNET: Configuring UE ETH for %s:%d\n",rrh_UE_ip,rrh_UE_port); - openair0_cfg[card].remote_addr = &rrh_UE_ip[0]; - openair0_cfg[card].remote_port = rrh_UE_port; - } - - openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL; - - openair0_cfg[card].clock_source = clock_source; - - openair0_cfg[card].tx_num_channels=min(2,((UE_flag==0) ? PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx)); - openair0_cfg[card].rx_num_channels=min(2,((UE_flag==0) ? PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_rx : PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx)); - - for (i=0; i<4; i++) { - - if (i<openair0_cfg[card].tx_num_channels) - openair0_cfg[card].tx_freq[i] = (UE_flag==0) ? downlink_frequency[0][i] : downlink_frequency[0][i]+uplink_frequency_offset[0][i]; - else - openair0_cfg[card].tx_freq[i]=0.0; - - if (i<openair0_cfg[card].rx_num_channels) - openair0_cfg[card].rx_freq[i] = (UE_flag==0) ? downlink_frequency[0][i] + uplink_frequency_offset[0][i] : downlink_frequency[0][i]; - else - openair0_cfg[card].rx_freq[i]=0.0; - - openair0_cfg[card].autocal[i] = 1; - openair0_cfg[card].tx_gain[i] = tx_gain[0][i]; - if (UE_flag == 0) { - openair0_cfg[card].rx_gain[i] = PHY_vars_eNB_g[0][0]->rx_total_gain_dB; - } - else { - openair0_cfg[card].rx_gain[i] = PHY_vars_UE_g[0][0]->rx_total_gain_dB - rx_gain_off; - } - - openair0_cfg[card].configFilename = rf_config_file; - printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n", - card,i, openair0_cfg[card].tx_gain[i], - openair0_cfg[card].rx_gain[i], - openair0_cfg[card].tx_freq[i], - openair0_cfg[card].rx_freq[i]); + for (i=0; i<4; i++) { + + if (i<openair0_cfg[card].tx_num_channels) + openair0_cfg[card].tx_freq[i] = (UE_flag==0) ? downlink_frequency[0][i] : downlink_frequency[0][i]+uplink_frequency_offset[0][i]; + else + openair0_cfg[card].tx_freq[i]=0.0; + + if (i<openair0_cfg[card].rx_num_channels) + openair0_cfg[card].rx_freq[i] = (UE_flag==0) ? downlink_frequency[0][i] + uplink_frequency_offset[0][i] : downlink_frequency[0][i]; + else + openair0_cfg[card].rx_freq[i]=0.0; + + openair0_cfg[card].autocal[i] = 1; + openair0_cfg[card].tx_gain[i] = tx_gain[0][i]; + if (UE_flag == 0) { + openair0_cfg[card].rx_gain[i] = PHY_vars_eNB_g[0][0]->rx_total_gain_dB; + } else { + openair0_cfg[card].rx_gain[i] = PHY_vars_UE_g[0][0]->rx_total_gain_dB - rx_gain_off; + } + + openair0_cfg[card].configFilename = rf_config_file; + printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n", + card,i, openair0_cfg[card].tx_gain[i], + openair0_cfg[card].rx_gain[i], + openair0_cfg[card].tx_freq[i], + openair0_cfg[card].rx_freq[i]); + } } - } } -int main( int argc, char **argv ) -{ - int i,j,k,aa,re; +int main( int argc, char **argv ) { + int i,j,k,aa,re; #if defined (XFORMS) - void *status; + void *status; #endif - int CC_id; - uint8_t abstraction_flag=0; - uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2; + int CC_id; + uint8_t abstraction_flag=0; + uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2; #if defined (XFORMS) - int ret; + int ret; #endif #ifdef DEBUG_CONSOLE - setvbuf(stdout, NULL, _IONBF, 0); - setvbuf(stderr, NULL, _IONBF, 0); + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); #endif - PHY_VARS_UE *UE[MAX_NUM_CCs]; + PHY_VARS_UE *UE[MAX_NUM_CCs]; + + mode = normal_txrx; + memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS); + + memset(tx_max_power,0,sizeof(int)*MAX_NUM_CCs); + set_latency_target(); - mode = normal_txrx; - memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS); + // set default parameters + set_default_frame_parms(frame_parms); - memset(tx_max_power,0,sizeof(int)*MAX_NUM_CCs); - set_latency_target(); + // initialize logging + logInit(); - // set default parameters - set_default_frame_parms(frame_parms); + // get options and fill parameters from configuration file + get_options (argc, argv); //Command-line options, enb_properties - // initialize logging - logInit(); - // get options and fill parameters from configuration file - get_options (argc, argv); //Command-line options, enb_properties - - #if T_TRACER - T_init(T_port, T_wait, T_dont_fork); + T_init(T_port, T_wait, T_dont_fork); #endif - // initialize the log (see log.h for details) - set_glog(glog_level, glog_verbosity); + // initialize the log (see log.h for details) + set_glog(glog_level, glog_verbosity); - //randominit (0); - set_taus_seed (0); + //randominit (0); + set_taus_seed (0); - if (UE_flag==1) { - printf("configuring for UE\n"); - - set_comp_log(HW, LOG_DEBUG, LOG_HIGH, 1); - set_comp_log(PHY, LOG_DEBUG, LOG_HIGH, 1); - set_comp_log(MAC, LOG_INFO, LOG_HIGH, 1); - set_comp_log(RLC, LOG_INFO, LOG_HIGH, 1); - set_comp_log(PDCP, LOG_INFO, LOG_HIGH, 1); - set_comp_log(OTG, LOG_INFO, LOG_HIGH, 1); - set_comp_log(RRC, LOG_INFO, LOG_HIGH, 1); + if (UE_flag==1) { + printf("configuring for UE\n"); + + set_comp_log(HW, LOG_DEBUG, LOG_HIGH, 1); + set_comp_log(PHY, LOG_DEBUG, LOG_HIGH, 1); + set_comp_log(MAC, LOG_INFO, LOG_HIGH, 1); + set_comp_log(RLC, LOG_INFO, LOG_HIGH, 1); + set_comp_log(PDCP, LOG_INFO, LOG_HIGH, 1); + set_comp_log(OTG, LOG_INFO, LOG_HIGH, 1); + set_comp_log(RRC, LOG_INFO, LOG_HIGH, 1); #if defined(ENABLE_ITTI) - set_comp_log(EMU, LOG_INFO, LOG_MED, 1); + set_comp_log(EMU, LOG_INFO, LOG_MED, 1); # if defined(ENABLE_USE_MME) - set_comp_log(NAS, LOG_INFO, LOG_HIGH, 1); + set_comp_log(NAS, LOG_INFO, LOG_HIGH, 1); # endif #endif - } else { - printf("configuring for eNB\n"); - - set_comp_log(HW, hw_log_level, hw_log_verbosity, 1); - set_comp_log(PHY, phy_log_level, phy_log_verbosity, 1); - if (opt_enabled == 1 ) - set_comp_log(OPT, opt_log_level, opt_log_verbosity, 1); - set_comp_log(MAC, mac_log_level, mac_log_verbosity, 1); - set_comp_log(RLC, rlc_log_level, rlc_log_verbosity, 1); - set_comp_log(PDCP, pdcp_log_level, pdcp_log_verbosity, 1); - set_comp_log(RRC, rrc_log_level, rrc_log_verbosity, 1); + } else { + printf("configuring for eNB\n"); + + set_comp_log(HW, hw_log_level, hw_log_verbosity, 1); + set_comp_log(PHY, phy_log_level, phy_log_verbosity, 1); + if (opt_enabled == 1 ) + set_comp_log(OPT, opt_log_level, opt_log_verbosity, 1); + set_comp_log(MAC, mac_log_level, mac_log_verbosity, 1); + set_comp_log(RLC, rlc_log_level, rlc_log_verbosity, 1); + set_comp_log(PDCP, pdcp_log_level, pdcp_log_verbosity, 1); + set_comp_log(RRC, rrc_log_level, rrc_log_verbosity, 1); #if defined(ENABLE_ITTI) - set_comp_log(EMU, LOG_INFO, LOG_MED, 1); + set_comp_log(EMU, LOG_INFO, LOG_MED, 1); # if defined(ENABLE_USE_MME) - set_comp_log(UDP_, udp_log_level, udp_log_verbosity, 1); - set_comp_log(GTPU, gtpu_log_level, gtpu_log_verbosity, 1); - set_comp_log(S1AP, LOG_DEBUG, LOG_HIGH, 1); - set_comp_log(SCTP, LOG_INFO, LOG_HIGH, 1); + set_comp_log(UDP_, udp_log_level, udp_log_verbosity, 1); + set_comp_log(GTPU, gtpu_log_level, gtpu_log_verbosity, 1); + set_comp_log(S1AP, LOG_DEBUG, LOG_HIGH, 1); + set_comp_log(SCTP, LOG_INFO, LOG_HIGH, 1); # endif #if defined(ENABLE_SECURITY) - set_comp_log(OSA, osa_log_level, osa_log_verbosity, 1); + set_comp_log(OSA, osa_log_level, osa_log_verbosity, 1); #endif #endif #ifdef LOCALIZATION - set_comp_log(LOCALIZE, LOG_DEBUG, LOG_LOW, 1); - set_component_filelog(LOCALIZE); + set_comp_log(LOCALIZE, LOG_DEBUG, LOG_LOW, 1); + set_component_filelog(LOCALIZE); #endif - set_comp_log(ENB_APP, LOG_INFO, LOG_HIGH, 1); - set_comp_log(OTG, LOG_INFO, LOG_HIGH, 1); + set_comp_log(ENB_APP, LOG_INFO, LOG_HIGH, 1); + set_comp_log(OTG, LOG_INFO, LOG_HIGH, 1); - if (online_log_messages == 1) { - set_component_filelog(RRC); - set_component_filelog(PDCP); + if (online_log_messages == 1) { + set_component_filelog(RRC); + set_component_filelog(PDCP); + } } - } - if (ouput_vcd) { - if (UE_flag==1) - VCD_SIGNAL_DUMPER_INIT("/tmp/openair_dump_UE.vcd"); - else - VCD_SIGNAL_DUMPER_INIT("/tmp/openair_dump_eNB.vcd"); - } + if (ouput_vcd) { + if (UE_flag==1) + VCD_SIGNAL_DUMPER_INIT("/tmp/openair_dump_UE.vcd"); + else + VCD_SIGNAL_DUMPER_INIT("/tmp/openair_dump_eNB.vcd"); + } - if (opp_enabled ==1){ - reset_opp_meas(); - } - cpuf=get_cpu_freq_GHz(); + if (opp_enabled ==1) { + reset_opp_meas(); + } + cpuf=get_cpu_freq_GHz(); #if defined(ENABLE_ITTI) - if (UE_flag == 1) { - log_set_instance_type (LOG_INSTANCE_UE); - } else { - log_set_instance_type (LOG_INSTANCE_ENB); - } + if (UE_flag == 1) { + log_set_instance_type (LOG_INSTANCE_UE); + } else { + log_set_instance_type (LOG_INSTANCE_ENB); + } + + itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file); - itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file); - - // initialize mscgen log after ITTI - MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX); + // initialize mscgen log after ITTI + MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX); #endif - - if (opt_type != OPT_NONE) { - radio_type_t radio_type; - if (frame_parms[0]->frame_type == FDD) - radio_type = RADIO_TYPE_FDD; - else - radio_type = RADIO_TYPE_TDD; + if (opt_type != OPT_NONE) { + radio_type_t radio_type; + + if (frame_parms[0]->frame_type == FDD) + radio_type = RADIO_TYPE_FDD; + else + radio_type = RADIO_TYPE_TDD; - if (init_opt(in_path, in_ip, NULL, radio_type) == -1) - LOG_E(OPT,"failed to run OPT \n"); - } + if (init_opt(in_path, in_ip, NULL, radio_type) == -1) + LOG_E(OPT,"failed to run OPT \n"); + } #ifdef PDCP_USE_NETLINK - netlink_init(); + netlink_init(); #if defined(PDCP_USE_NETLINK_QUEUES) - pdcp_netlink_init(); + pdcp_netlink_init(); #endif #endif #if !defined(ENABLE_ITTI) - // to make a graceful exit when ctrl-c is pressed - signal(SIGSEGV, signal_handler); - signal(SIGINT, signal_handler); + // to make a graceful exit when ctrl-c is pressed + signal(SIGSEGV, signal_handler); + signal(SIGINT, signal_handler); #endif - check_clock(); + check_clock(); - // init the parameters - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - - if (UE_flag==1) { - frame_parms[CC_id]->nb_antennas_tx = 1; - frame_parms[CC_id]->nb_antennas_rx = 1; - frame_parms[CC_id]->nb_antenna_ports_eNB = 1; //initial value overwritten by initial sync later - } + // init the parameters + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - init_ul_hopping(frame_parms[CC_id]); - init_frame_parms(frame_parms[CC_id],1); - // phy_init_top(frame_parms[CC_id]); - phy_init_lte_top(frame_parms[CC_id]); - } + if (UE_flag==1) { + frame_parms[CC_id]->nb_antennas_tx = 1; + frame_parms[CC_id]->nb_antennas_rx = 1; + frame_parms[CC_id]->nb_antenna_ports_eNB = 1; //initial value overwritten by initial sync later + } + init_ul_hopping(frame_parms[CC_id]); + init_frame_parms(frame_parms[CC_id],1); + // phy_init_top(frame_parms[CC_id]); + phy_init_lte_top(frame_parms[CC_id]); + } - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - //init prach for openair1 test - // prach_fmt = get_prach_fmt(frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, frame_parms->frame_type); - // N_ZC = (prach_fmt <4)?839:139; - } + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + //init prach for openair1 test - if (UE_flag==1) { - NB_UE_INST=1; - NB_INST=1; + // prach_fmt = get_prach_fmt(frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, frame_parms->frame_type); + // N_ZC = (prach_fmt <4)?839:139; + } - PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE**)); - PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_UE*)*MAX_NUM_CCs); + if (UE_flag==1) { + NB_UE_INST=1; + NB_INST=1; + + PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE**)); + PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_UE*)*MAX_NUM_CCs); + + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + + PHY_vars_UE_g[0][CC_id] = init_lte_UE(frame_parms[CC_id], 0,abstraction_flag); + UE[CC_id] = PHY_vars_UE_g[0][CC_id]; + printf("PHY_vars_UE_g[0][%d] = %p\n",CC_id,UE[CC_id]); + + if (phy_test==1) + UE[CC_id]->mac_enabled = 0; + else + UE[CC_id]->mac_enabled = 1; + + if (UE[CC_id]->mac_enabled == 0) { //set default UL parameters for testing mode + for (i=0; i<NUMBER_OF_CONNECTED_eNB_MAX; i++) { + UE[CC_id]->pusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK; + UE[CC_id]->pusch_config_dedicated[i].betaOffset_RI_Index = beta_RI; + UE[CC_id]->pusch_config_dedicated[i].betaOffset_CQI_Index = beta_CQI; + + UE[CC_id]->scheduling_request_config[i].sr_PUCCH_ResourceIndex = 0; + UE[CC_id]->scheduling_request_config[i].sr_ConfigIndex = 7+(0%3); + UE[CC_id]->scheduling_request_config[i].dsr_TransMax = sr_n4; + } + } + + UE[CC_id]->UE_scan = UE_scan; + UE[CC_id]->UE_scan_carrier = UE_scan_carrier; + UE[CC_id]->mode = mode; + printf("UE[%d]->mode = %d\n",CC_id,mode); + + compute_prach_seq(&UE[CC_id]->frame_parms.prach_config_common, + UE[CC_id]->frame_parms.frame_type, + UE[CC_id]->X_u); + + if (UE[CC_id]->mac_enabled == 1) + UE[CC_id]->pdcch_vars[0]->crnti = 0x1234; + else + UE[CC_id]->pdcch_vars[0]->crnti = 0x1235; + + UE[CC_id]->rx_total_gain_dB = (int)rx_gain[CC_id][0] + rx_gain_off; + UE[CC_id]->tx_power_max_dBm = tx_max_power[CC_id]; + + if (frame_parms[CC_id]->frame_type==FDD) { + UE[CC_id]->N_TA_offset = 0; + } else { + if (frame_parms[CC_id]->N_RB_DL == 100) + UE[CC_id]->N_TA_offset = 624; + else if (frame_parms[CC_id]->N_RB_DL == 50) + UE[CC_id]->N_TA_offset = 624/2; + else if (frame_parms[CC_id]->N_RB_DL == 25) + UE[CC_id]->N_TA_offset = 624/4; + } - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + } - PHY_vars_UE_g[0][CC_id] = init_lte_UE(frame_parms[CC_id], 0,abstraction_flag); - UE[CC_id] = PHY_vars_UE_g[0][CC_id]; - printf("PHY_vars_UE_g[0][%d] = %p\n",CC_id,UE[CC_id]); - - if (phy_test==1) - UE[CC_id]->mac_enabled = 0; - else - UE[CC_id]->mac_enabled = 1; - - if (UE[CC_id]->mac_enabled == 0) { //set default UL parameters for testing mode - for (i=0; i<NUMBER_OF_CONNECTED_eNB_MAX; i++) { - UE[CC_id]->pusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK; - UE[CC_id]->pusch_config_dedicated[i].betaOffset_RI_Index = beta_RI; - UE[CC_id]->pusch_config_dedicated[i].betaOffset_CQI_Index = beta_CQI; - - UE[CC_id]->scheduling_request_config[i].sr_PUCCH_ResourceIndex = 0; - UE[CC_id]->scheduling_request_config[i].sr_ConfigIndex = 7+(0%3); - UE[CC_id]->scheduling_request_config[i].dsr_TransMax = sr_n4; - } - } - - UE[CC_id]->UE_scan = UE_scan; - UE[CC_id]->UE_scan_carrier = UE_scan_carrier; - UE[CC_id]->mode = mode; - printf("UE[%d]->mode = %d\n",CC_id,mode); - - compute_prach_seq(&UE[CC_id]->frame_parms.prach_config_common, - UE[CC_id]->frame_parms.frame_type, - UE[CC_id]->X_u); - - if (UE[CC_id]->mac_enabled == 1) - UE[CC_id]->pdcch_vars[0]->crnti = 0x1234; - else - UE[CC_id]->pdcch_vars[0]->crnti = 0x1235; - - UE[CC_id]->rx_total_gain_dB = (int)rx_gain[CC_id][0] + rx_gain_off; - UE[CC_id]->tx_power_max_dBm = tx_max_power[CC_id]; - - if (frame_parms[CC_id]->frame_type==FDD) { - UE[CC_id]->N_TA_offset = 0; - } - else { - if (frame_parms[CC_id]->N_RB_DL == 100) - UE[CC_id]->N_TA_offset = 624; - else if (frame_parms[CC_id]->N_RB_DL == 50) - UE[CC_id]->N_TA_offset = 624/2; - else if (frame_parms[CC_id]->N_RB_DL == 25) - UE[CC_id]->N_TA_offset = 624/4; - } + // printf("tx_max_power = %d -> amp %d\n",tx_max_power,get_tx_amp(tx_max_poHwer,tx_max_power)); + } else { + //this is eNB + PHY_vars_eNB_g = malloc(sizeof(PHY_VARS_eNB**)); + PHY_vars_eNB_g[0] = malloc(sizeof(PHY_VARS_eNB*)); + + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + PHY_vars_eNB_g[0][CC_id] = init_lte_eNB(frame_parms[CC_id],0,frame_parms[CC_id]->Nid_cell,node_function[CC_id],abstraction_flag); + PHY_vars_eNB_g[0][CC_id]->ue_dl_rb_alloc=0x1fff; + PHY_vars_eNB_g[0][CC_id]->target_ue_dl_mcs=target_dl_mcs; + PHY_vars_eNB_g[0][CC_id]->ue_ul_nb_rb=6; + PHY_vars_eNB_g[0][CC_id]->target_ue_ul_mcs=target_ul_mcs; + // initialization for phy-test + for (k=0; k<NUMBER_OF_UE_MAX; k++) { + PHY_vars_eNB_g[0][CC_id]->transmission_mode[k] = transmission_mode; + if (transmission_mode==7) + lte_gold_ue_spec_port5(PHY_vars_eNB_g[0][CC_id]->lte_gold_uespec_port5_table[k],frame_parms[CC_id]->Nid_cell,0x1235+k); + } + if ((transmission_mode==1) || (transmission_mode==7)) { + for (j=0; j<frame_parms[CC_id]->nb_antennas_tx; j++) + for (re=0; re<frame_parms[CC_id]->ofdm_symbol_size; re++) + PHY_vars_eNB_g[0][CC_id]->common_vars.beam_weights[0][0][j][re] = 0x00007fff/frame_parms[CC_id]->nb_antennas_tx; + } + + if (phy_test==1) PHY_vars_eNB_g[0][CC_id]->mac_enabled = 0; + else PHY_vars_eNB_g[0][CC_id]->mac_enabled = 1; + + if (PHY_vars_eNB_g[0][CC_id]->mac_enabled == 0) { //set default parameters for testing mode + for (i=0; i<NUMBER_OF_UE_MAX; i++) { + PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK; + PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_RI_Index = beta_RI; + PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_CQI_Index = beta_CQI; + + PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_PUCCH_ResourceIndex = i; + PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_ConfigIndex = 7+(i%3); + PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].dsr_TransMax = sr_n4; + } + } + + compute_prach_seq(&PHY_vars_eNB_g[0][CC_id]->frame_parms.prach_config_common, + PHY_vars_eNB_g[0][CC_id]->frame_parms.frame_type, + PHY_vars_eNB_g[0][CC_id]->X_u); + + + PHY_vars_eNB_g[0][CC_id]->rx_total_gain_dB = (int)rx_gain[CC_id][0]; + + if (frame_parms[CC_id]->frame_type==FDD) { + PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 0; + } else { + if (frame_parms[CC_id]->N_RB_DL == 100) + PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624; + else if (frame_parms[CC_id]->N_RB_DL == 50) + PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624/2; + else if (frame_parms[CC_id]->N_RB_DL == 25) + PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624/4; + } - } + } - // printf("tx_max_power = %d -> amp %d\n",tx_max_power,get_tx_amp(tx_max_poHwer,tx_max_power)); - } else { - //this is eNB - PHY_vars_eNB_g = malloc(sizeof(PHY_VARS_eNB**)); - PHY_vars_eNB_g[0] = malloc(sizeof(PHY_VARS_eNB*)); - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - PHY_vars_eNB_g[0][CC_id] = init_lte_eNB(frame_parms[CC_id],0,frame_parms[CC_id]->Nid_cell,node_function[CC_id],abstraction_flag); - PHY_vars_eNB_g[0][CC_id]->ue_dl_rb_alloc=0x1fff; - PHY_vars_eNB_g[0][CC_id]->target_ue_dl_mcs=target_dl_mcs; - PHY_vars_eNB_g[0][CC_id]->ue_ul_nb_rb=6; - PHY_vars_eNB_g[0][CC_id]->target_ue_ul_mcs=target_ul_mcs; - // initialization for phy-test - for (k=0;k<NUMBER_OF_UE_MAX;k++) { - PHY_vars_eNB_g[0][CC_id]->transmission_mode[k] = transmission_mode; - if (transmission_mode==7) - lte_gold_ue_spec_port5(PHY_vars_eNB_g[0][CC_id]->lte_gold_uespec_port5_table[k],frame_parms[CC_id]->Nid_cell,0x1235+k); - } - if ((transmission_mode==1) || (transmission_mode==7)) { - for (j=0; j<frame_parms[CC_id]->nb_antennas_tx; j++) - for (re=0; re<frame_parms[CC_id]->ofdm_symbol_size; re++) - PHY_vars_eNB_g[0][CC_id]->common_vars.beam_weights[0][0][j][re] = 0x00007fff/frame_parms[CC_id]->nb_antennas_tx; - } - - if (phy_test==1) PHY_vars_eNB_g[0][CC_id]->mac_enabled = 0; - else PHY_vars_eNB_g[0][CC_id]->mac_enabled = 1; - - if (PHY_vars_eNB_g[0][CC_id]->mac_enabled == 0) { //set default parameters for testing mode - for (i=0; i<NUMBER_OF_UE_MAX; i++) { - PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK; - PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_RI_Index = beta_RI; - PHY_vars_eNB_g[0][CC_id]->pusch_config_dedicated[i].betaOffset_CQI_Index = beta_CQI; - - PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_PUCCH_ResourceIndex = i; - PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].sr_ConfigIndex = 7+(i%3); - PHY_vars_eNB_g[0][CC_id]->scheduling_request_config[i].dsr_TransMax = sr_n4; - } - } - - compute_prach_seq(&PHY_vars_eNB_g[0][CC_id]->frame_parms.prach_config_common, - PHY_vars_eNB_g[0][CC_id]->frame_parms.frame_type, - PHY_vars_eNB_g[0][CC_id]->X_u); - - - PHY_vars_eNB_g[0][CC_id]->rx_total_gain_dB = (int)rx_gain[CC_id][0]; - - if (frame_parms[CC_id]->frame_type==FDD) { - PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 0; - } - else { - if (frame_parms[CC_id]->N_RB_DL == 100) - PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624; - else if (frame_parms[CC_id]->N_RB_DL == 50) - PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624/2; - else if (frame_parms[CC_id]->N_RB_DL == 25) - PHY_vars_eNB_g[0][CC_id]->N_TA_offset = 624/4; - } + NB_eNB_INST=1; + NB_INST=1; } - - - NB_eNB_INST=1; - NB_INST=1; - - } - fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx); - cpuf=get_cpu_freq_GHz(); + fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx); + cpuf=get_cpu_freq_GHz(); - dump_frame_parms(frame_parms[0]); + dump_frame_parms(frame_parms[0]); - init_openair0(); + init_openair0(); #ifndef DEADLINE_SCHEDULER - /* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */ - - cpu_set_t cpuset; - int s; - char cpu_affinity[1024]; - CPU_ZERO(&cpuset); + /* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */ + + cpu_set_t cpuset; + int s; + char cpu_affinity[1024]; + CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY - if (get_nprocs() > 2) - { - CPU_SET(0, &cpuset); - s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - if (s != 0) - { - perror( "pthread_setaffinity_np"); - exit_fun("Error setting processor affinity"); - } - LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); + if (get_nprocs() > 2) { + CPU_SET(0, &cpuset); + s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + if (s != 0) { + perror( "pthread_setaffinity_np"); + exit_fun("Error setting processor affinity"); + } + LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); } #endif - /* Check the actual affinity mask assigned to the thread */ - s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - if (s != 0) - { - perror( "pthread_getaffinity_np"); - exit_fun("Error getting processor affinity "); + /* Check the actual affinity mask assigned to the thread */ + s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + if (s != 0) { + perror( "pthread_getaffinity_np"); + exit_fun("Error getting processor affinity "); } - memset(cpu_affinity, 0 , sizeof(cpu_affinity)); - for (int j = 0; j < CPU_SETSIZE; j++) - { - if (CPU_ISSET(j, &cpuset)) - { - char temp[1024]; - sprintf(temp, " CPU_%d ", j); - strcat(cpu_affinity, temp); - } + memset(cpu_affinity, 0 , sizeof(cpu_affinity)); + for (int j = 0; j < CPU_SETSIZE; j++) { + if (CPU_ISSET(j, &cpuset)) { + char temp[1024]; + sprintf(temp, " CPU_%d ", j); + strcat(cpu_affinity, temp); + } } - LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity); + LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity); #endif - - openair0_cfg[0].log_level = glog_level; - + openair0_cfg[0].log_level = glog_level; - int eMBMS_active=0; - if (node_function[0] <= NGFI_RAU_IF4p5) { // don't initialize L2 for RRU - LOG_I(PHY,"Intializing L2\n"); - mac_xface = malloc(sizeof(MAC_xface)); - l2_init(frame_parms[0],eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL, - 0,// cba_group_active - 0); // HO flag - mac_xface->macphy_exit = &exit_fun; - } - else if (node_function[0] == NGFI_RRU_IF4p5) { // Initialize PRACH in this case - } + + int eMBMS_active=0; + if (node_function[0] <= NGFI_RAU_IF4p5) { // don't initialize L2 for RRU + LOG_I(PHY,"Intializing L2\n"); + mac_xface = malloc(sizeof(MAC_xface)); + l2_init(frame_parms[0],eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL, + 0,// cba_group_active + 0); // HO flag + mac_xface->macphy_exit = &exit_fun; + } else if (node_function[0] == NGFI_RRU_IF4p5) { // Initialize PRACH in this case + + } #if defined(ENABLE_ITTI) - if ((UE_flag == 1)|| - (node_function[0]<NGFI_RAU_IF4p5)) - // don't create if node doesn't connect to RRC/S1/GTP - if (create_tasks(UE_flag ? 0 : 1, UE_flag ? 1 : 0) < 0) { - printf("cannot create ITTI tasks\n"); - exit(-1); // need a softer mode - } + if ((UE_flag == 1)|| + (node_function[0]<NGFI_RAU_IF4p5)) + // don't create if node doesn't connect to RRC/S1/GTP + if (create_tasks(UE_flag ? 0 : 1, UE_flag ? 1 : 0) < 0) { + printf("cannot create ITTI tasks\n"); + exit(-1); // need a softer mode + } - printf("ITTI tasks created\n"); + printf("ITTI tasks created\n"); #endif - if (phy_test==0) { - if (UE_flag==1) { - printf("Filling UE band info\n"); - fill_ue_band_info(); - mac_xface->dl_phy_sync_success (0, 0, 0, 1); - } else if (node_function[0]>NGFI_RRU_IF4p5) - mac_xface->mrbch_phy_sync_failure (0, 0, 0); - } + if (phy_test==0) { + if (UE_flag==1) { + printf("Filling UE band info\n"); + fill_ue_band_info(); + mac_xface->dl_phy_sync_success (0, 0, 0, 1); + } else if (node_function[0]>NGFI_RRU_IF4p5) + mac_xface->mrbch_phy_sync_failure (0, 0, 0); + } - mlockall(MCL_CURRENT | MCL_FUTURE); + mlockall(MCL_CURRENT | MCL_FUTURE); - pthread_cond_init(&sync_cond,NULL); - pthread_mutex_init(&sync_mutex, NULL); + pthread_cond_init(&sync_cond,NULL); + pthread_mutex_init(&sync_mutex, NULL); #ifdef XFORMS - int UE_id; - - if (do_forms==1) { - fl_initialize (&argc, argv, NULL, 0, 0); - - if (UE_flag==0) { - form_stats_l2 = create_form_stats_form(); - fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats"); - form_stats = create_form_stats_form(); - fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); - - for(UE_id=0; UE_id<scope_enb_num_ue; UE_id++) { - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - form_enb[CC_id][UE_id] = create_lte_phy_scope_enb(); - sprintf (title, "LTE UL SCOPE eNB for CC_id %d, UE %d",CC_id,UE_id); - fl_show_form (form_enb[CC_id][UE_id]->lte_phy_scope_enb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); - - if (otg_enabled) { - fl_set_button(form_enb[CC_id][UE_id]->button_0,1); - fl_set_object_label(form_enb[CC_id][UE_id]->button_0,"DL Traffic ON"); - } else { - fl_set_button(form_enb[CC_id][UE_id]->button_0,0); - fl_set_object_label(form_enb[CC_id][UE_id]->button_0,"DL Traffic OFF"); - } - } // CC_id - } // UE_id - } else { - form_stats = create_form_stats_form(); - fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); - UE_id = 0; - form_ue[UE_id] = create_lte_phy_scope_ue(); - sprintf (title, "LTE DL SCOPE UE"); - fl_show_form (form_ue[UE_id]->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); - - /* - if (openair_daq_vars.use_ia_receiver) { - fl_set_button(form_ue[UE_id]->button_0,1); - fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver ON"); - } else { - fl_set_button(form_ue[UE_id]->button_0,0); - fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver OFF"); - }*/ - fl_set_button(form_ue[UE_id]->button_0,0); - fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver OFF"); - } + int UE_id; + + if (do_forms==1) { + fl_initialize (&argc, argv, NULL, 0, 0); + + if (UE_flag==0) { + form_stats_l2 = create_form_stats_form(); + fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats"); + form_stats = create_form_stats_form(); + fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); + + for(UE_id=0; UE_id<scope_enb_num_ue; UE_id++) { + for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + form_enb[CC_id][UE_id] = create_lte_phy_scope_enb(); + sprintf (title, "LTE UL SCOPE eNB for CC_id %d, UE %d",CC_id,UE_id); + fl_show_form (form_enb[CC_id][UE_id]->lte_phy_scope_enb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); + + if (otg_enabled) { + fl_set_button(form_enb[CC_id][UE_id]->button_0,1); + fl_set_object_label(form_enb[CC_id][UE_id]->button_0,"DL Traffic ON"); + } else { + fl_set_button(form_enb[CC_id][UE_id]->button_0,0); + fl_set_object_label(form_enb[CC_id][UE_id]->button_0,"DL Traffic OFF"); + } + } // CC_id + } // UE_id + } else { + form_stats = create_form_stats_form(); + fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); + UE_id = 0; + form_ue[UE_id] = create_lte_phy_scope_ue(); + sprintf (title, "LTE DL SCOPE UE"); + fl_show_form (form_ue[UE_id]->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); + + /* + if (openair_daq_vars.use_ia_receiver) { + fl_set_button(form_ue[UE_id]->button_0,1); + fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver ON"); + } else { + fl_set_button(form_ue[UE_id]->button_0,0); + fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver OFF"); + }*/ + fl_set_button(form_ue[UE_id]->button_0,0); + fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver OFF"); + } - ret = pthread_create(&forms_thread, NULL, scope_thread, NULL); + ret = pthread_create(&forms_thread, NULL, scope_thread, NULL); - if (ret == 0) - pthread_setname_np( forms_thread, "xforms" ); + if (ret == 0) + pthread_setname_np( forms_thread, "xforms" ); - printf("Scope thread created, ret=%d\n",ret); - } + printf("Scope thread created, ret=%d\n",ret); + } #endif - rt_sleep_ns(10*100000000ULL); + rt_sleep_ns(10*100000000ULL); - // start the main thread - if (UE_flag == 1) { - init_UE(1); - number_of_cards = 1; - - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - PHY_vars_UE_g[0][CC_id]->rf_map.card=0; - PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+chain_offset; - } - } - else { - printf("Initializing eNB threads\n"); - init_eNB(node_function,node_timing,1,eth_params,single_thread_flag,wait_for_sync); + // start the main thread + if (UE_flag == 1) { + init_UE(1); + number_of_cards = 1; - number_of_cards = 1; - - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - PHY_vars_eNB_g[0][CC_id]->rf_map.card=0; - PHY_vars_eNB_g[0][CC_id]->rf_map.chain=CC_id+chain_offset; + for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + PHY_vars_UE_g[0][CC_id]->rf_map.card=0; + PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+chain_offset; + } + } else { + printf("Initializing eNB threads\n"); + init_eNB(node_function,node_timing,1,eth_params,single_thread_flag,wait_for_sync); + + number_of_cards = 1; + + for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + PHY_vars_eNB_g[0][CC_id]->rf_map.card=0; + PHY_vars_eNB_g[0][CC_id]->rf_map.chain=CC_id+chain_offset; + } } - } - // connect the TX/RX buffers - if (UE_flag==1) { + // connect the TX/RX buffers + if (UE_flag==1) { + + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - for (CC_id=0;CC_id<MAX_NUM_CCs; CC_id++) { - #ifdef OAI_USRP - UE[CC_id]->hw_timing_advance = timing_advance; + UE[CC_id]->hw_timing_advance = timing_advance; #else - UE[CC_id]->hw_timing_advance = 160; + UE[CC_id]->hw_timing_advance = 160; #endif - } - if (setup_ue_buffers(UE,&openair0_cfg[0])!=0) { - printf("Error setting up eNB buffer\n"); - exit(-1); - } + } + if (setup_ue_buffers(UE,&openair0_cfg[0])!=0) { + printf("Error setting up eNB buffer\n"); + exit(-1); + } - if (input_fd) { - printf("Reading in from file to antenna buffer %d\n",0); - if (fread(UE[0]->common_vars.rxdata[0], - sizeof(int32_t), - frame_parms[0]->samples_per_tti*10, - input_fd) != frame_parms[0]->samples_per_tti*10) - printf("error reading from file\n"); - } - //p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX; - } else { + if (input_fd) { + printf("Reading in from file to antenna buffer %d\n",0); + if (fread(UE[0]->common_vars.rxdata[0], + sizeof(int32_t), + frame_parms[0]->samples_per_tti*10, + input_fd) != frame_parms[0]->samples_per_tti*10) + printf("error reading from file\n"); + } + //p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX; + } else { - printf("Setting eNB buffer to all-RX\n"); + printf("Setting eNB buffer to all-RX\n"); - // Set LSBs for antenna switch (ExpressMIMO) - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - PHY_vars_eNB_g[0][CC_id]->hw_timing_advance = 0; - for (i=0; i<frame_parms[CC_id]->samples_per_tti*10; i++) - for (aa=0; aa<frame_parms[CC_id]->nb_antennas_tx; aa++) - PHY_vars_eNB_g[0][CC_id]->common_vars.txdata[0][aa][i] = 0x00010001; + // Set LSBs for antenna switch (ExpressMIMO) + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + PHY_vars_eNB_g[0][CC_id]->hw_timing_advance = 0; + for (i=0; i<frame_parms[CC_id]->samples_per_tti*10; i++) + for (aa=0; aa<frame_parms[CC_id]->nb_antennas_tx; aa++) + PHY_vars_eNB_g[0][CC_id]->common_vars.txdata[0][aa][i] = 0x00010001; + } } - } - sleep(3); + sleep(3); - printf("Sending sync to all threads\n"); + printf("Sending sync to all threads\n"); - pthread_mutex_lock(&sync_mutex); - sync_var=0; - pthread_cond_broadcast(&sync_cond); - pthread_mutex_unlock(&sync_mutex); + pthread_mutex_lock(&sync_mutex); + sync_var=0; + pthread_cond_broadcast(&sync_cond); + pthread_mutex_unlock(&sync_mutex); - // wait for end of program - printf("TYPE <CTRL-C> TO TERMINATE\n"); - //getchar(); + // wait for end of program + printf("TYPE <CTRL-C> TO TERMINATE\n"); + //getchar(); #if defined(ENABLE_ITTI) - printf("Entering ITTI signals handler\n"); - itti_wait_tasks_end(); - oai_exit=1; + printf("Entering ITTI signals handler\n"); + itti_wait_tasks_end(); + oai_exit=1; #else - while (oai_exit==0) - rt_sleep_ns(100000000ULL); + while (oai_exit==0) + rt_sleep_ns(100000000ULL); #endif - // stop threads + // stop threads #ifdef XFORMS - printf("waiting for XFORMS thread\n"); + printf("waiting for XFORMS thread\n"); - if (do_forms==1) { - pthread_join(forms_thread,&status); - fl_hide_form(form_stats->stats_form); - fl_free_form(form_stats->stats_form); + if (do_forms==1) { + pthread_join(forms_thread,&status); + fl_hide_form(form_stats->stats_form); + fl_free_form(form_stats->stats_form); - if (UE_flag==1) { - fl_hide_form(form_ue[0]->lte_phy_scope_ue); - fl_free_form(form_ue[0]->lte_phy_scope_ue); - } else { - fl_hide_form(form_stats_l2->stats_form); - fl_free_form(form_stats_l2->stats_form); - - for(UE_id=0; UE_id<scope_enb_num_ue; UE_id++) { - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - fl_hide_form(form_enb[CC_id][UE_id]->lte_phy_scope_enb); - fl_free_form(form_enb[CC_id][UE_id]->lte_phy_scope_enb); - } - } + if (UE_flag==1) { + fl_hide_form(form_ue[0]->lte_phy_scope_ue); + fl_free_form(form_ue[0]->lte_phy_scope_ue); + } else { + fl_hide_form(form_stats_l2->stats_form); + fl_free_form(form_stats_l2->stats_form); + + for(UE_id=0; UE_id<scope_enb_num_ue; UE_id++) { + for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + fl_hide_form(form_enb[CC_id][UE_id]->lte_phy_scope_enb); + fl_free_form(form_enb[CC_id][UE_id]->lte_phy_scope_enb); + } + } + } } - } #endif - printf("stopping MODEM threads\n"); + printf("stopping MODEM threads\n"); - // cleanup - if (UE_flag == 1) { - } else { - stop_eNB(1); - } + // cleanup + if (UE_flag == 1) { + } else { + stop_eNB(1); + } - pthread_cond_destroy(&sync_cond); - pthread_mutex_destroy(&sync_mutex); + pthread_cond_destroy(&sync_cond); + pthread_mutex_destroy(&sync_mutex); - // *** Handle per CC_id openair0 - if (UE_flag==1) { - if (PHY_vars_UE_g[0][0]->rfdevice.trx_end_func) - PHY_vars_UE_g[0][0]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][0]->rfdevice); - } - else { - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - if (PHY_vars_eNB_g[0][CC_id]->rfdevice.trx_end_func) - PHY_vars_eNB_g[0][CC_id]->rfdevice.trx_end_func(&PHY_vars_eNB_g[0][CC_id]->rfdevice); - if (PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_end_func) - PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_end_func(&PHY_vars_eNB_g[0][CC_id]->ifdevice); + // *** Handle per CC_id openair0 + if (UE_flag==1) { + if (PHY_vars_UE_g[0][0]->rfdevice.trx_end_func) + PHY_vars_UE_g[0][0]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][0]->rfdevice); + } else { + for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + if (PHY_vars_eNB_g[0][CC_id]->rfdevice.trx_end_func) + PHY_vars_eNB_g[0][CC_id]->rfdevice.trx_end_func(&PHY_vars_eNB_g[0][CC_id]->rfdevice); + if (PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_end_func) + PHY_vars_eNB_g[0][CC_id]->ifdevice.trx_end_func(&PHY_vars_eNB_g[0][CC_id]->ifdevice); + } } - } - if (ouput_vcd) - VCD_SIGNAL_DUMPER_CLOSE(); + if (ouput_vcd) + VCD_SIGNAL_DUMPER_CLOSE(); - if (opt_enabled == 1) - terminate_opt(); + if (opt_enabled == 1) + terminate_opt(); - logClean(); + logClean(); - return 0; + return 0; } diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h new file mode 100644 index 0000000000000000000000000000000000000000..e499bd12be3ac22e8e37e584801001a06dd0939c --- /dev/null +++ b/targets/RT/USER/lte-softmodem.h @@ -0,0 +1,95 @@ +#ifndef LTE_SOFTMODEM_H +#define LTE_SOFTMODEM_H + +#define _GNU_SOURCE +#include <execinfo.h> +#include <fcntl.h> +#include <getopt.h> +#include <linux/sched.h> +#include "rt_wrapper.h" +#include <sched.h> +#include <signal.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <syscall.h> +#include <sys/ioctl.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <sys/sysinfo.h> +#include <sys/types.h> +#include <unistd.h> + +#include <sys/sysinfo.h> +#include "rt_wrapper.h" +#include "../../ARCH/COMMON/common_lib.h" +#undef MALLOC +#include "assertions.h" +#include "msc.h" +#include "PHY/types.h" +#include "PHY/defs.h" +#include "SIMULATION/ETH_TRANSPORT/proto.h" + +#if defined(ENABLE_ITTI) +#if defined(ENABLE_USE_MME) +#include "s1ap_eNB.h" +#ifdef PDCP_USE_NETLINK +#include "SIMULATION/ETH_TRANSPORT/proto.h" +#endif +#endif +#endif + +extern pthread_cond_t sync_cond; +extern pthread_mutex_t sync_mutex; +extern int sync_var; + + +extern uint32_t downlink_frequency[MAX_NUM_CCs][4]; +extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; + +extern int rx_input_level_dBm; +extern uint8_t exit_missed_slots; +extern uint64_t num_missed_slots; // counter for the number of missed slots + +extern int oaisim_flag; +extern volatile int oai_exit; + +extern openair0_config_t openair0_cfg[MAX_CARDS]; +extern pthread_cond_t sync_cond; +extern pthread_mutex_t sync_mutex; +extern int sync_var; +extern int transmission_mode; +extern double cpuf; + +#if defined(ENABLE_ITTI) +extern volatile int start_eNB; +extern volatile int start_UE; +#endif + +typedef struct threads_s { + int iq; + int odd; + int even; +} threads_t; +extern threads_t threads; + +extern void exit_fun(const char* s); +// In lte-enb.c +extern int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_cfg); +extern void init_eNB(eNB_func_t *, eNB_timing_t *,int,eth_params_t *,int,int); +extern void stop_eNB(int); +extern void kill_eNB_proc(int inst); + +// In lte-ue.c +extern int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg); +extern void fill_ue_band_info(void); +extern void init_UE(int); +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 *); + +#endif diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 0a7c87a152bdb51cbb499ac642e31ad182d1cfce..decc793411aaef50e460840d07ad053e819e84de 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -29,29 +29,10 @@ * \note * \warning */ -#define _GNU_SOURCE -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <sched.h> -#include <linux/sched.h> -#include <signal.h> -#include <execinfo.h> -#include <getopt.h> -#include <syscall.h> -#include <sys/sysinfo.h> +#include "lte-softmodem.h" #include "rt_wrapper.h" -#include "assertions.h" -#include "PHY/types.h" -#include "PHY/defs.h" #ifdef OPENAIR2 #include "LAYER2/MAC/defs.h" #include "RRC/LITE/extern.h" @@ -61,8 +42,6 @@ #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all -#include "../../ARCH/COMMON/common_lib.h" - #include "PHY/extern.h" #include "SCHED/extern.h" #include "LAYER2/MAC/extern.h" @@ -91,30 +70,11 @@ void init_UE_threads(PHY_VARS_UE *UE); void *UE_thread(void *arg); void init_UE(int nb_inst); -extern pthread_cond_t sync_cond; -extern pthread_mutex_t sync_mutex; -extern int sync_var; - - -extern openair0_config_t openair0_cfg[MAX_CARDS]; -extern uint32_t downlink_frequency[MAX_NUM_CCs][4]; -extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; -extern int oai_exit; - int32_t **rxdata; int32_t **txdata; -//extern unsigned int tx_forward_nsamps; -//extern int tx_delay; - -extern int rx_input_level_dBm; -extern uint8_t exit_missed_slots; -extern uint64_t num_missed_slots; // counter for the number of missed slots - -extern void exit_fun(const char* s); - #define KHz (1000UL) -#define MHz (1000 * KHz) +#define MHz (1000*KHz) typedef struct eutra_band_s { int16_t band; @@ -186,7 +146,7 @@ void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_ } #else - if (cpuset!=NULL) + if (CPU_COUNT(cpuset) > 0) AssertFatal( 0 == pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), cpuset), ""); struct sched_param sp; sp.sched_priority = sched_fifo; @@ -246,7 +206,8 @@ static void *UE_thread_synch(void *arg) { cpu_set_t cpuset; CPU_ZERO(&cpuset); - CPU_SET(3, &cpuset); + if ( threads.iq != -1 ) + CPU_SET(threads.iq, &cpuset); // this thread priority must be lower that the main acquisition thread init_thread(100000, 500000, FIFO_PRIORITY-1, &cpuset, "sync UE"); @@ -510,7 +471,10 @@ static void *UE_thread_rxn_txnp4(void *arg) { sprintf(threadname,"UE_proc_%d",proc->sub_frame_start); cpu_set_t cpuset; CPU_ZERO(&cpuset); - CPU_SET(proc->sub_frame_start+1, &cpuset); + if ( (proc->sub_frame_start+1)%2 == 0 && threads.even != -1 ) + CPU_SET(threads.even, &cpuset); + if ( (proc->sub_frame_start+1)%2 == 1 && threads.odd != -1 ) + CPU_SET(threads.odd, &cpuset); init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset, threadname); @@ -624,12 +588,14 @@ void *UE_thread(void *arg) { cpu_set_t cpuset; CPU_ZERO(&cpuset); - CPU_SET(3, &cpuset); + if ( threads.iq != -1 ) + CPU_SET(threads.iq, &cpuset); init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, - "main UE"); - - AssertFatal(0== openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]), ""); + "UHD Threads"); + if (oaisim_flag == 0) + AssertFatal(0== openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]), ""); UE->rfdevice.host_type = BBU_HOST; + pthread_setname_np( pthread_self(), "Main UE" ); init_UE_threads(UE); #ifdef NAS_UE diff --git a/targets/SIMU/USER/channel_sim.c b/targets/SIMU/USER/channel_sim.c index 514f87693979ca0f64d884a32881068fa872c92e..370e50d145257253df3662f8e2dc80f0177a2799 100644 --- a/targets/SIMU/USER/channel_sim.c +++ b/targets/SIMU/USER/channel_sim.c @@ -557,7 +557,7 @@ void do_UL_sig(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX_N #ifdef DEBUG_SIM rx_pwr2 = signal_energy(rxdata[0]+sf_offset,frame_parms->samples_per_tti)*(double)frame_parms->ofdm_symbol_size/(12.0*frame_parms->N_RB_DL); - LOG_D(OCM,"[SIM][UL] eNB %d rx_pwr (ADC out) %f dB (%d) for subframe %d\n",eNB_id,10*log10((double)rx_pwr2),rx_pwr2,subframe); + LOG_D(OCM,"[SIM][UL] eNB %d rx_pwr (ADC out) %f dB (%d) for subframe %d (offset %d)\n",eNB_id,10*log10((double)rx_pwr2),rx_pwr2,subframe,sf_offset); #else UNUSED_VARIABLE(tx_pwr); UNUSED_VARIABLE(rx_pwr); diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 23665f6763194e2c0e3fc9db8fb90a3d66fa4048..71bfce44cb1a1ce2ef54927491d10c07ac8e6ed1 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -574,7 +574,8 @@ l2l1_task (void *args_p) itti_mark_task_ready (TASK_L2L1); LOG_I(EMU, "TASK_L2L1 is READY\n"); - if (oai_emulation.info.nb_enb_local > 0) { + if ((oai_emulation.info.nb_enb_local > 0) && + (oai_emulation.info.node_function[0] < NGFI_RAU_IF4p5)) { /* Wait for the initialize message */ do { if (message_p != NULL) { @@ -706,6 +707,8 @@ l2l1_task (void *args_p) update_ocm (); for (sf = 0; sf < 10; sf++) { + LOG_D(EMU,"************************* Subframe %d\n",sf); + start_meas (&oaisim_stats_f); wait_for_slot_isr (); @@ -742,7 +745,7 @@ l2l1_task (void *args_p) (subframe_UE_mask_local == ((1<<NB_UE_INST)-1))) all_done=1; else - usleep(500); + usleep(1500); } //clear subframe masks for next round @@ -1001,7 +1004,8 @@ l2l1_task (void *args_p) do_DL_sig (r_re0, r_im0, r_re, - r_im, + r_im,n + s_re, s_im, eNB2UE, @@ -1074,7 +1078,7 @@ l2l1_task (void *args_p) } - + /* if ((frame >= 10) && (frame <= 11) && (abstraction_flag == 0) #ifdef PROC &&(Channel_Flag==0) @@ -1121,6 +1125,7 @@ l2l1_task (void *args_p) * 10, 1, 1); } + */ //#ifdef XFORMS if (xforms==1) { @@ -1286,7 +1291,25 @@ main (int argc, char **argv) init_openair2 (); + init_openair0(); + init_ocm (); + +#if defined(ENABLE_ITTI) + // Handle signals until all tasks are terminated + + // Note: Cannot handle both RRU/RAU and eNB at the same time, if the first "eNB" is an RRU/RAU, no NAS + if (oai_emulation.info.node_function[0] < NGFI_RAU_IF4p5) { + if (create_tasks(oai_emulation.info.nb_enb_local, + oai_emulation.info.nb_ue_local) < 0) + exit(-1); // need a softer mode + } + else { + if (create_tasks(0, + oai_emulation.info.nb_ue_local) < 0) + exit(-1); // need a softer mode + } +#endif // wait for all threads to startup sleep(3); @@ -1327,12 +1350,8 @@ main (int argc, char **argv) #if defined(ENABLE_ITTI) - // Handle signals until all tasks are terminated - if (create_tasks(oai_emulation.info.nb_enb_local, oai_emulation.info.nb_ue_local) >= 0) { - itti_wait_tasks_end(); - } else { - exit(-1); // need a softer mode - } + itti_wait_tasks_end(); + #else diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c index 508ebcde27804d8f8856657c1b19ce3882f131cc..7fa29843bea688633d309a0f32bc2525330505c8 100644 --- a/targets/SIMU/USER/oaisim_functions.c +++ b/targets/SIMU/USER/oaisim_functions.c @@ -77,6 +77,9 @@ # include "s1ap_eNB.h" #endif +#include "../../ARCH/COMMON/common_lib.h" +#include "../../ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" + #ifdef SMBV extern uint8_t config_smbv; extern char smbv_ip[16]; @@ -88,6 +91,8 @@ extern char smbv_ip[16]; #define K 2 // averaging coefficient #define TARGET_SF_TIME_NS 1000000 // 1ms = 1000000 ns +#define min(a,b) ((a)<(b)?(a):(b)) + int otg_times = 0; int if_times = 0; int for_times = 0; @@ -170,11 +175,14 @@ extern int xforms; extern uint32_t downlink_frequency[MAX_NUM_CCs][4]; extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; -void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst); +eth_params_t *eth_params; + +void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst,eth_params_t *,int,int); void stop_eNB(int nb_inst); const Enb_properties_array_t *enb_properties; +int oaisim_flag=1; void get_simulation_options(int argc, char *argv[]) { @@ -788,7 +796,33 @@ void get_simulation_options(int argc, char *argv[]) AssertFatal (oai_emulation.info.nb_enb_local <= enb_properties->number, "Number of eNB is greater than eNB defined in configuration file %s (%d/%d)!", conf_config_file_name, oai_emulation.info.nb_enb_local, enb_properties->number); + + eth_params = (eth_params_t*)malloc(enb_properties->properties[0]->nb_rrh_gw * sizeof(eth_params_t)); + memset(eth_params, 0, enb_properties->properties[0]->nb_rrh_gw * sizeof(eth_params_t)); + for (int j=0; j<enb_properties->properties[0]->nb_rrh_gw; j++) { + + if (enb_properties->properties[0]->rrh_gw_config[j].active == 1 ) { + // local_remote_radio = BBU_REMOTE_RADIO_HEAD; + (eth_params+j)->local_if_name = enb_properties->properties[0]->rrh_gw_config[j].rrh_gw_if_name; + (eth_params+j)->my_addr = enb_properties->properties[0]->rrh_gw_config[j].local_address; + (eth_params+j)->my_port = enb_properties->properties[0]->rrh_gw_config[j].local_port; + (eth_params+j)->remote_addr = enb_properties->properties[0]->rrh_gw_config[j].remote_address; + (eth_params+j)->remote_port = enb_properties->properties[0]->rrh_gw_config[j].remote_port; + + if (enb_properties->properties[0]->rrh_gw_config[j].raw == 1) { + (eth_params+j)->transp_preference = ETH_RAW_MODE; + } else if (enb_properties->properties[0]->rrh_gw_config[j].rawif4p5 == 1) { + (eth_params+j)->transp_preference = ETH_RAW_IF4p5_MODE; + } else if (enb_properties->properties[0]->rrh_gw_config[j].udpif4p5 == 1) { + (eth_params+j)->transp_preference = ETH_UDP_IF4p5_MODE; + } else if (enb_properties->properties[0]->rrh_gw_config[j].rawif5_mobipass == 1) { + (eth_params+j)->transp_preference = ETH_RAW_IF5_MOBIPASS; + } else { + (eth_params+j)->transp_preference = ETH_UDP_MODE; + } + } + } /* Update some simulation parameters */ oai_emulation.info.frame_type[0] = enb_properties->properties[0]->frame_type[0]; oai_emulation.info.tdd_config[0] = enb_properties->properties[0]->tdd_config[0]; @@ -799,6 +833,7 @@ void get_simulation_options(int argc, char *argv[]) oai_emulation.info.node_timing[0] = enb_properties->properties[0]->cc_node_timing[0]; downlink_frequency[0][0] = enb_properties->properties[0]->downlink_frequency[0]; uplink_frequency_offset[0][0] = enb_properties->properties[0]->uplink_frequency_offset[0]; + oai_emulation.info.N_RB_DL[0] = enb_properties->properties[0]->N_RB_DL[0]; } free(conf_config_file_name); @@ -1010,7 +1045,7 @@ int eNB_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void * *ptimestamp = last_eNB_rx_timestamp[eNB_id][CC_id]; - LOG_D(PHY,"eNB_trx_read nsamps %d TS(%llu,%llu) => subframe %d\n",nsamps, + LOG_D(EMU,"eNB_trx_read nsamps %d TS(%llu,%llu) => subframe %d\n",nsamps, (unsigned long long)current_eNB_rx_timestamp[eNB_id][CC_id], (unsigned long long)last_eNB_rx_timestamp[eNB_id][CC_id], (*ptimestamp/PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.samples_per_tti)%10); @@ -1019,7 +1054,7 @@ int eNB_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void * while (sample_count<nsamps) { while (current_eNB_rx_timestamp[eNB_id][CC_id]< (nsamps+last_eNB_rx_timestamp[eNB_id][CC_id])) { - LOG_D(EMU,"eNB: current TS %llu, last TS %llu, sleeping\n",current_eNB_rx_timestamp[eNB_id][CC_id],last_eNB_rx_timestamp[eNB_id][CC_id]); + // LOG_D(EMU,"eNB: current TS %llu, last TS %llu, sleeping\n",current_eNB_rx_timestamp[eNB_id][CC_id],last_eNB_rx_timestamp[eNB_id][CC_id]); usleep(500); } @@ -1029,7 +1064,7 @@ int eNB_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void * pthread_mutex_unlock(&subframe_mutex); subframe = (last_eNB_rx_timestamp[eNB_id][CC_id]/PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.samples_per_tti)%10; - LOG_D(PHY,"eNB_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n", + LOG_D(EMU,"eNB_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n", subframe,(unsigned long long)*ptimestamp, (unsigned long long)current_eNB_rx_timestamp[eNB_id][CC_id]); @@ -1075,12 +1110,12 @@ int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void ** while (sample_count<nsamps) { while (current_UE_rx_timestamp[UE_id][CC_id] < (last_UE_rx_timestamp[UE_id][CC_id]+read_size)) { - LOG_D(EMU,"UE_trx_read : current TS %d, last TS %d, sleeping\n",current_UE_rx_timestamp[UE_id][CC_id],last_UE_rx_timestamp[UE_id][CC_id]); + //LOG_D(EMU,"UE_trx_read : current TS %d, last TS %d, sleeping\n",current_UE_rx_timestamp[UE_id][CC_id],last_UE_rx_timestamp[UE_id][CC_id]); usleep(500); } - LOG_D(EMU,"UE_trx_read : current TS %d, last TS %d, sleeping\n",current_UE_rx_timestamp[UE_id][CC_id],last_UE_rx_timestamp[UE_id][CC_id]); + // LOG_D(EMU,"UE_trx_read : current TS %d, last TS %d, sleeping\n",current_UE_rx_timestamp[UE_id][CC_id],last_UE_rx_timestamp[UE_id][CC_id]); // tell top-level we are busy pthread_mutex_lock(&subframe_mutex); @@ -1128,6 +1163,85 @@ int UE_trx_write(openair0_device *device,openair0_timestamp timestamp, void **bu return(nsamps); } +void init_openair0(void); + +openair0_config_t openair0_cfg[MAX_CARDS]; + +void init_openair0() { + + int card; + int i; + + for (card=0; card<MAX_CARDS; card++) { + + openair0_cfg[card].configFilename = NULL; + + if(frame_parms[0]->N_RB_DL == 100) { + if (frame_parms[0]->threequarter_fs) { + openair0_cfg[card].sample_rate=23.04e6; + openair0_cfg[card].samples_per_frame = 230400; + openair0_cfg[card].tx_bw = 10e6; + openair0_cfg[card].rx_bw = 10e6; + } + else { + openair0_cfg[card].sample_rate=30.72e6; + openair0_cfg[card].samples_per_frame = 307200; + openair0_cfg[card].tx_bw = 10e6; + openair0_cfg[card].rx_bw = 10e6; + } + } else if(frame_parms[0]->N_RB_DL == 50) { + openair0_cfg[card].sample_rate=15.36e6; + openair0_cfg[card].samples_per_frame = 153600; + openair0_cfg[card].tx_bw = 5e6; + openair0_cfg[card].rx_bw = 5e6; + } else if (frame_parms[0]->N_RB_DL == 25) { + openair0_cfg[card].sample_rate=7.68e6; + openair0_cfg[card].samples_per_frame = 76800; + openair0_cfg[card].tx_bw = 2.5e6; + openair0_cfg[card].rx_bw = 2.5e6; + } else if (frame_parms[0]->N_RB_DL == 6) { + openair0_cfg[card].sample_rate=1.92e6; + openair0_cfg[card].samples_per_frame = 19200; + openair0_cfg[card].tx_bw = 1.5e6; + openair0_cfg[card].rx_bw = 1.5e6; + } + + if (frame_parms[0]->frame_type==TDD) + openair0_cfg[card].duplex_mode = duplex_mode_TDD; + else //FDD + openair0_cfg[card].duplex_mode = duplex_mode_FDD; + + + openair0_cfg[card].remote_addr = (eth_params+card)->remote_addr; + openair0_cfg[card].remote_port = (eth_params+card)->remote_port; + openair0_cfg[card].my_addr = (eth_params+card)->my_addr; + openair0_cfg[card].my_port = (eth_params+card)->my_port; + + + printf("HW: Configuring card %d, nb_antennas_tx/rx %d/%d\n",card, + PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx, + PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_rx); + openair0_cfg[card].Mod_id = 0; + + + + openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL; + openair0_cfg[card].tx_num_channels=min(2,PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx); + openair0_cfg[card].rx_num_channels=min(2,PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_rx); + + for (i=0; i<4; i++) { + + openair0_cfg[card].rx_gain[i] = PHY_vars_eNB_g[0][0]->rx_total_gain_dB; + + printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n", + card,i, openair0_cfg[card].tx_gain[i], + openair0_cfg[card].rx_gain[i], + openair0_cfg[card].tx_freq[i], + openair0_cfg[card].rx_freq[i]); + } + } +} + void init_devices(void){ module_id_t UE_id, eNB_id; @@ -1180,7 +1294,7 @@ void init_openair1(void) oai_emulation.info.tdd_config_S[CC_id], oai_emulation.info.extended_prefix_flag[CC_id], oai_emulation.info.N_RB_DL[CC_id], - Nid_cell, + enb_properties->properties[0]->Nid_cell[CC_id], cooperation_flag, enb_properties->properties[0]->nb_antenna_ports[CC_id], abstraction_flag, @@ -1188,6 +1302,11 @@ void init_openair1(void) enb_properties->properties[0]->nb_antennas_tx[CC_id], nb_antennas_rx_ue, oai_emulation.info.eMBMS_active_state); + + // This is for IF4p5 RRU, gets done by RRC configuration of eNB + PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex = enb_properties->properties[0]->prach_config_index[CC_id]; + PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset = enb_properties->properties[0]->prach_freq_offset[CC_id]; + } for (eNB_id=0; eNB_id<NB_eNB_INST; eNB_id++) { @@ -1272,7 +1391,7 @@ void init_openair1(void) init_devices (); - init_eNB(oai_emulation.info.node_function,oai_emulation.info.node_timing,NB_eNB_INST); + init_eNB(oai_emulation.info.node_function,oai_emulation.info.node_timing,NB_eNB_INST,eth_params,1,0); // init_ue_status(); for (UE_id=0; UE_id<NB_UE_INST; UE_id++) { @@ -1283,9 +1402,10 @@ void init_openair1(void) PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB=100; // update UE_mode for each eNB_id not just 0 - if (abstraction_flag == 0) - PHY_vars_UE_g[UE_id][CC_id]->UE_mode[0] = NOT_SYNCHED; - else { + if (abstraction_flag == 0) { + if (phy_test==0) PHY_vars_UE_g[UE_id][CC_id]->UE_mode[0] = NOT_SYNCHED; + else PHY_vars_UE_g[UE_id][CC_id]->UE_mode[0] = PUSCH; + } else { // 0 is the index of the connected eNB PHY_vars_UE_g[UE_id][CC_id]->UE_mode[0] = PRACH; } @@ -1822,6 +1942,7 @@ void init_time() td_avg = TARGET_SF_TIME_NS; } +/* int openair0_transport_load(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t * eth_params) { return(0); @@ -1833,3 +1954,4 @@ int openair0_device_load(openair0_device *device, openair0_config_t *openair0_cf return(0); } +*/