From dcf25f35c7f27c53905aeaaa55e3dbde5999f488 Mon Sep 17 00:00:00 2001 From: Srushti Date: Fri, 21 Jun 2019 11:11:42 +0200 Subject: [PATCH 1/3] added PRACH UE Procedures into prachsim --- cmake_targets/build_oai | 2 +- openair1/PHY/defs_nr_UE.h | 1 + openair1/PHY/defs_nr_common.h | 1 + openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 190 ++++++++++++++++++++ openair1/SIMULATION/NR_PHY/prachsim.c | 12 +- 5 files changed, 201 insertions(+), 5 deletions(-) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index c03d178067..355bf090f3 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -684,7 +684,7 @@ function main() { echo_info "Compiling unitary tests simulators" # TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim #simlist="dlsim_tm4 dlsim ulsim pucchsim prachsim pdcchsim pbchsim mbmssim" - simlist="nr_pucchsim dlsim ulsim polartest ldpctest smallblocktest nr_pbchsim nr_dlschsim nr_dlsim nr_ulschsim nr_prachsim" + simlist="nr_prachsim nr_pucchsim dlsim ulsim polartest ldpctest smallblocktest nr_pbchsim nr_dlschsim nr_dlsim nr_ulschsim " for f in $simlist ; do compilations \ phy_simulators $f \ diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index cb2200898c..dd7127a8e2 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -1035,6 +1035,7 @@ typedef struct { int current_dlsch_cqi[NUMBER_OF_CONNECTED_eNB_MAX]; unsigned char first_run_timing_advance[NUMBER_OF_CONNECTED_eNB_MAX]; uint8_t generate_prach; + uint8_t generate_nr_prach; uint8_t prach_cnt; uint8_t prach_PreambleIndex; // uint8_t prach_timer; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index ef41afe58a..6f3d45a4c5 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -242,6 +242,7 @@ typedef struct NR_DL_FRAME_PARMS { /// total Number of Resource Block Groups: this is ceil(N_PRB/P) /// Frame type (0 FDD, 1 TDD) lte_frame_type_t frame_type; + uint8_t tdd_config; /// Cell ID uint16_t Nid_cell; /// subcarrier spacing (15,30,60,120) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 57c48127b8..cec59ead51 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -4798,3 +4798,193 @@ uint8_t is_ri_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id) else return(0); } + +void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode) { + + int frame_tx = proc->frame_tx; + int nr_tti_tx = proc->nr_tti_tx; + int prach_power; + uint16_t preamble_tx=50; + PRACH_RESOURCES_t prach_resources; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_IN); + + ue->generate_nr_prach=0; + if (ue->mac_enabled==0){ + ue->prach_resources[eNB_id] = &prach_resources; + ue->prach_resources[eNB_id]->ra_PreambleIndex = preamble_tx; + ue->prach_resources[eNB_id]->ra_TDD_map_index = 0; + } + + if (ue->mac_enabled==1){ + + // ask L2 for RACH transport + if ((mode != rx_calib_ue) && (mode != rx_calib_ue_med) && (mode != rx_calib_ue_byp) && (mode != no_L2_connect) ) { + LOG_D(PHY,"Getting PRACH resources\n"); + //ue->prach_resources[eNB_id] = mac_xface->ue_get_rach(ue->Mod_id,ue->CC_id,frame_tx,eNB_id,nr_tti_tx); + // LOG_D(PHY,"Got prach_resources for eNB %d address %p, RRCCommon %p\n",eNB_id,ue->prach_resources[eNB_id],UE_mac_inst[ue->Mod_id].radioResourceConfigCommon); + // LOG_D(PHY,"Prach resources %p\n",ue->prach_resources[eNB_id]); + } +} + +if (ue->prach_resources[eNB_id]!=NULL) { + + ue->generate_nr_prach=1; + ue->prach_cnt=0; +#ifdef SMBV +ue->prach_resources[eNB_id]->ra_PreambleIndex = preamble_tx; +#endif + +#ifdef OAI_EMU + ue->prach_PreambleIndex=ue->prach_resources[eNB_id]->ra_PreambleIndex; +#endif + + if (abstraction_flag == 0) { + + LOG_I(PHY,"mode %d\n",mode); + + if ((ue->mac_enabled==1) && (mode != calib_prach_tx)) { + + ue->tx_power_dBm[nr_tti_tx] = ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER+get_nr_PL(ue,eNB_id); + } + else { + ue->tx_power_dBm[nr_tti_tx] = ue->tx_power_max_dBm; + ue->prach_resources[eNB_id]->ra_PreambleIndex = preamble_tx; + } + + LOG_I(PHY,"[UE %d][RAPROC] Frame %d, nr_tti_rx %d : Generating PRACH, preamble %d,PL %d, P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, PRACH TDD Resource index %d, RA-RNTI %d\n", + ue->Mod_id, + frame_tx, + nr_tti_tx, + ue->prach_resources[eNB_id]->ra_PreambleIndex, + get_nr_PL(ue,eNB_id), + ue->tx_power_dBm[nr_tti_tx], + ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER, + ue->prach_resources[eNB_id]->ra_TDD_map_index, + ue->prach_resources[eNB_id]->ra_RNTI); + + ue->tx_total_RE[nr_tti_tx] = 96; + +#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706) + ue->prach_vars[eNB_id]->amp = get_tx_amp(ue->tx_power_dBm[nr_tti_tx], + ue->tx_power_max_dBm, + ue->frame_parms.N_RB_UL, + 6); +#else + ue->prach_vars[eNB_id]->amp = AMP; +#endif + if ((mode == calib_prach_tx) && (((proc->frame_tx&0xfffe)%100)==0)) + LOG_D(PHY,"[UE %d][RAPROC] Frame %d, nr_tti_rx %d : PRACH TX power %d dBm, amp %d\n", + ue->Mod_id, + proc->frame_rx, + proc->nr_tti_tx, + ue->tx_power_dBm[nr_tti_tx], + ue->prach_vars[eNB_id]->amp); + + + // start_meas(&ue->tx_prach); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GENERATE_PRACH, VCD_FUNCTION_IN); + +// prach_power = generate_nr_prach(ue,eNB_id,nr_tti_tx,frame_tx); +prach_power = generate_nr_prach(ue,0,9,0); //subframe number hardcoded according to the simulator + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GENERATE_PRACH, VCD_FUNCTION_OUT); + // stop_meas(&ue->tx_prach); + LOG_D(PHY,"[UE %d][RAPROC] PRACH PL %d dB, power %d dBm, digital power %d dB (amp %d)\n", + ue->Mod_id, + get_nr_PL(ue,eNB_id), + ue->tx_power_dBm[nr_tti_tx], + dB_fixed(prach_power), + ue->prach_vars[eNB_id]->amp); + }/* else { + UE_transport_info[ue->Mod_id][ue->CC_id].cntl.prach_flag=1; + UE_transport_info[ue->Mod_id][ue->CC_id].cntl.prach_id=ue->prach_resources[eNB_id]->ra_PreambleIndex; + }*/ // commented for compiling as abstraction flag is 0 + + if (ue->mac_enabled==1){ + //mac_xface->Msg1_transmitted(ue->Mod_id,ue->CC_id,frame_tx,eNB_id); + } + +LOG_I(PHY,"[UE %d][RAPROC] Frame %d, nr_tti_rx %d: Generating PRACH (eNB %d) preamble index %d for UL, TX power %d dBm (PL %d dB), l3msg \n", + ue->Mod_id,frame_tx,nr_tti_tx,eNB_id, + ue->prach_resources[eNB_id]->ra_PreambleIndex, + ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER+get_nr_PL(ue,eNB_id), + get_nr_PL(ue,eNB_id)); + +} + + +// if we're calibrating the PRACH kill the pointer to its resources so that the RA protocol doesn't continue +if (mode == calib_prach_tx) + ue->prach_resources[eNB_id]=NULL; + +LOG_D(PHY,"[UE %d] frame %d nr_tti_rx %d : generate_nr_prach %d, prach_cnt %d\n", + ue->Mod_id,frame_tx,nr_tti_tx,ue->generate_nr_prach,ue->prach_cnt); + +ue->prach_cnt++; + +if (ue->prach_cnt==3) + ue->generate_nr_prach=0; + +VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_OUT); +} + + +//Yet to be done +/* void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode,relaying_type_t r_type) { + + NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; + int32_t ulsch_start=0; + int nr_tti_tx = proc->nr_tti_tx; + int frame_tx = proc->frame_tx; + unsigned int aa; + uint8_t isSubframeSRS; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX,VCD_FUNCTION_IN); + + LOG_D(PHY,"****** start TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, nr_tti_tx); + ue->generate_ul_signal[eNB_id] = 0; + + +#if UE_TIMING_TRACE + start_meas(&ue->phy_proc_tx); +#endif + + ue->tx_power_dBm[nr_tti_tx]=-127; +printf("ue mode =%d\n",ue->UE_mode[eNB_id]); + + if (abstraction_flag==0) { + for (aa=0; aanb_antennas_tx; aa++) { + memset(&ue->common_vars.txdataF[aa][nr_tti_tx*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti],0,frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti*sizeof(int32_t)); + } + } + +if (abstraction_flag == 0) { + ulsch_common_procedures(ue,proc, (ue->generate_ul_signal[eNB_id] == 0)); + } + +ue->UE_mode[eNB_id]=1; +ue->frame_parms.prach_config_common.prach_Config_enabled=1; +printf("S: ue->UE_mode[eNB_id] == PRACH is %d and ue->frame_parms.prach_config_common.prach_Config_enabled is %d\n", ue->UE_mode[eNB_id],ue->frame_parms.prach_config_common.prach_Config_enabled); + if ((ue->UE_mode[eNB_id] == PRACH) && + (ue->frame_parms.prach_config_common.prach_Config_enabled==1)) { + + // check if we have PRACH opportunity + if (is_nr_prach_subframe(&ue->frame_parms,frame_tx,nr_tti_tx)) { +printf("the value of is_nr_prach subframe is %d\n",is_nr_prach_subframe(&ue->frame_parms,frame_tx,nr_tti_tx)); + nr_ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode); + } + } // mode is PRACH + else { + ue->generate_prach=0; + } + +LOG_D(PHY,"****** end TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, nr_tti_tx); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); +#if UE_TIMING_TRACE + stop_meas(&ue->phy_proc_tx); +#endif +} */ + + diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index f2296128c6..f3a83870d6 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -114,7 +114,7 @@ int main(int argc, char **argv) int N_RB_UL=273; uint32_t prach_errors=0; uint8_t subframe=9; - uint16_t preamble_energy_list[64],preamble_tx=99,preamble_delay_list[64]; + uint16_t preamble_energy_list[64],preamble_tx=50,preamble_delay_list[64]; uint16_t preamble_max,preamble_energy_max; PRACH_RESOURCES_t prach_resources; //uint8_t prach_fmt; @@ -514,10 +514,14 @@ int main(int argc, char **argv) UE->prach_resources[0]->ra_PreambleIndex = preamble_tx; UE->prach_resources[0]->ra_TDD_map_index = 0; - tx_lev = generate_nr_prach(UE, + /*tx_lev = generate_nr_prach(UE, 0, //gNB_id, subframe, - 0); //Nf + 0); //Nf */ //commented for testing purpose + +UE_nr_rxtx_proc_t proc={0}; +nr_ue_prach_procedures(UE,&proc,0,0,0); + /* tx_lev_dB not used later, no need to set */ //tx_lev_dB = (unsigned int) dB_fixed(tx_lev); @@ -603,7 +607,7 @@ int main(int argc, char **argv) if (preamble_rx!=preamble_tx) prach_errors++; else { - delay_avg += (double)preamble_delay_list[preamble_max]; + delay_avg += (double)preamble_delay_list[preamble_tx]; } if (n_frames==1) { From 62dd59d868c3f481ad93a7f5ee86e1cd9d653cb1 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Tue, 25 Jun 2019 17:28:09 +0200 Subject: [PATCH 2/3] attempt to solve a couple of segmentation faults --- executables/nr-gnb.c | 17 ++++++----------- executables/nr-ru.c | 2 +- openair1/PHY/INIT/nr_init.c | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index d589ec02d6..745cc03565 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -701,8 +701,7 @@ void init_gNB_proc(int inst) { PHY_VARS_gNB *gNB; gNB_L1_proc_t *proc; gNB_L1_rxtx_proc_t *L1_proc,*L1_proc_tx; - LOG_I(PHY,"%s(inst:%d) RC.nb_nr_CC[inst]:%d \n",__FUNCTION__,inst,RC.nb_nr_CC[inst]); - +// LOG_I(PHY,"%s(inst:%d) RC.nb_nr_CC[inst]:%d \n",__FUNCTION__,inst,RC.nb_nr_CC[inst]); gNB = RC.gNB[inst]; #ifndef OCP_FRAMEWORK LOG_I(PHY,"Initializing gNB processes instance:%d CC_id %d \n",inst,CC_id); @@ -753,7 +752,6 @@ void init_gNB_proc(int inst) { AssertFatal(proc->instance_cnt_prach == -1,"instance_cnt_prach = %d\n",proc->instance_cnt_prach); - /* 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); @@ -852,19 +850,18 @@ void init_eNB_afterRU(void) { LOG_I(PHY,"%s() RC.nb_nr_inst:%d\n", __FUNCTION__, RC.nb_nr_inst); for (inst=0; instnum_RU>0,"Number of RU attached to gNB %d is zero\n",gNB->Mod_id); - + LOG_I(PHY,"Mapping RX ports from %d RUs to gNB %d\n",gNB->num_RU,gNB->Mod_id); //LOG_I(PHY,"Overwriting gNB->prach_vars.rxsigF[0]:%p\n", gNB->prach_vars.rxsigF[0]); gNB->prach_vars.rxsigF[0] = (int16_t **)malloc16(64*sizeof(int16_t *)); LOG_I(PHY,"gNB->num_RU:%d\n", gNB->num_RU); - + for (ru_id=0,aa=0; ru_idnum_RU; ru_id++) { AssertFatal(gNB->RU_list[ru_id]->common.rxdataF!=NULL, "RU %d : common.rxdataF is NULL\n", @@ -879,16 +876,14 @@ void init_eNB_afterRU(void) { gNB->common_vars.rxdataF[aa] = gNB->RU_list[ru_id]->common.rxdataF[i]; } } - + /* TODO: review this code, there is something wrong. * In monolithic mode, we come here with nb_antennas_rx == 0 * (not tested in other modes). */ //init_precoding_weights(RC.gNB[inst]); + init_gNB_proc(inst); } - - init_gNB_proc(inst); - for (ru_id=0; ru_idfh_north_asynch_in) { + if (ru->fh_north_asynch_in) { if (nr_slot_select(&ru->gNB_list[0]->gNB_config,subframe)!=SF_UL) ru->fh_north_asynch_in(ru,&frame,&subframe); } else AssertFatal(1==0,"Unknown function in ru_thread_asynch_rxtx\n"); diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 570abcc97b..2d0661728e 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -185,7 +185,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, */ // PRACH prach_vars->prachF = (int16_t *)malloc16_clear( 1024*2*sizeof(int16_t) ); - + prach_vars->rxsigF = (int16_t *)malloc16_clear( 1024*2*sizeof(int16_t) ); prach_vars->prach_ifft = (int32_t *)malloc16_clear(1024*2*sizeof(int32_t)); /* From d342e2d12b23a21c136739f716063498061fcde2 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Fri, 28 Jun 2019 10:12:00 +0200 Subject: [PATCH 3/3] fix for ssb periodicity --- openair2/LAYER2/NR_MAC_gNB/config.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 9aa1458f14..c0df31e797 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -81,6 +81,26 @@ void config_common(int Mod_idP, int mu = 1; + switch (*scc->ssb_periodicityServingCell) { + case 0: + cfg->sch_config.ssb_periodicity.value = 5; + break; + case 1: + cfg->sch_config.ssb_periodicity.value = 10; + break; + case 2: + cfg->sch_config.ssb_periodicity.value = 20; + break; + case 3: + cfg->sch_config.ssb_periodicity.value = 40; + break; + case 4: + cfg->sch_config.ssb_periodicity.value = 80; + break; + case 5: + cfg->sch_config.ssb_periodicity.value = 160; + break; + } cfg->sch_config.physical_cell_id.value = *scc->physCellId; cfg->sch_config.ssb_scg_position_in_burst.value = scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0];