From 1905611d255748f6ea9746eb0830ea080466fea2 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 5 Feb 2020 15:02:05 +0100 Subject: [PATCH 1/4] making ulsim run again, nr_dlsim should run again in CI --- .../{rcc-files => rrc-files}/rbconfig.raw | 0 .../{rcc-files => rrc-files}/reconfig.raw | Bin ci-scripts/runTestOnVM.sh | 2 +- cmake_targets/CMakeLists.txt | 3 +- cmake_targets/autotests/test_case_list.xml | 30 +++-- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 2 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 4 +- openair1/SIMULATION/NR_PHY/dlsim.c | 15 +-- openair1/SIMULATION/NR_PHY/ulsim.c | 116 +++++++++++++++--- .../NR_MAC_UE/nr_ue_dci_configuration.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 3 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 2 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 +- 13 files changed, 136 insertions(+), 45 deletions(-) rename ci-scripts/{rcc-files => rrc-files}/rbconfig.raw (100%) rename ci-scripts/{rcc-files => rrc-files}/reconfig.raw (100%) diff --git a/ci-scripts/rcc-files/rbconfig.raw b/ci-scripts/rrc-files/rbconfig.raw similarity index 100% rename from ci-scripts/rcc-files/rbconfig.raw rename to ci-scripts/rrc-files/rbconfig.raw diff --git a/ci-scripts/rcc-files/reconfig.raw b/ci-scripts/rrc-files/reconfig.raw similarity index 100% rename from ci-scripts/rcc-files/reconfig.raw rename to ci-scripts/rrc-files/reconfig.raw diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh index 8efe6e3257..74cffeedd4 100755 --- a/ci-scripts/runTestOnVM.sh +++ b/ci-scripts/runTestOnVM.sh @@ -1260,7 +1260,7 @@ function start_rf_sim_nr_ue { echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 if [ $LOC_S1_CONFIGURATION -eq 0 ] then - echo "echo \"RFSIMULATOR=${LOC_GNB_VM_IP_ADDR} ./nr-uesoftmodem --numerology 1 -C ${LOC_FREQUENCY}000000 -r $LOC_PRB --nokrnmod 1 --rfsim --phy-test --rcc_config_path /home/ubuntu/tmp/ci-scripts/rcc-files --log_config.global_log_options level,nocolor --noS1\" > ./my-nr-softmodem-run.sh " >> $1 + echo "echo \"RFSIMULATOR=${LOC_GNB_VM_IP_ADDR} ./nr-uesoftmodem --numerology 1 -C ${LOC_FREQUENCY}000000 -r $LOC_PRB --nokrnmod 1 --rfsim --phy-test --rcc_config_path /home/ubuntu/tmp/ci-scripts/rrc-files --log_config.global_log_options level,nocolor --noS1\" > ./my-nr-softmodem-run.sh " >> $1 fi echo "chmod 775 ./my-nr-softmodem-run.sh" >> $1 echo "cat ./my-nr-softmodem-run.sh" >> $1 diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 356328d7dc..b84ffd38a0 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -127,7 +127,7 @@ endfunction() #set(CMAKE_BUILD_TYPE "Debug") if (CMAKE_BUILD_TYPE STREQUAL "") - set(CMAKE_BUILD_TYPE "Release") + set(CMAKE_BUILD_TYPE "RelWithDebInfo") endif() message("CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}") add_list_string_option(CMAKE_BUILD_TYPE "RelWithDebInfo" "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." Debug Release RelWithDebInfo MinSizeRel) @@ -2766,7 +2766,6 @@ target_link_libraries(nr_pucchsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl ) -#PUCCH ---> Prashanth add_executable(nr_dlsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index c4f15c3a16..eea6c037ae 100644 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1089,25 +1089,29 @@ (Test8: 217 PRB 100 PDSCH-PRBs), (Test9: 217 PRB 80 PDSCH-Offset), (Test10: 217 PRB 100 PDSCH-PRBs 110 PDSCH-Offset), - (Test11: 106 PRBs 50 PDSCH-PRBs MCS Index 28 + (Test11: 106 PRBs 50 PDSCH-PRBs MCS Index 28) + (Test12: 106 PRBs 50 PDSCH-PRBs MCS Index 16) $OPENAIR_DIR/cmake_targets/build_oai --phy_simulators -c $OPENAIR_DIR/cmake_targets/autotests/tools/free_mem.bash $OPENAIR_DIR/targets/bin/nr_dlsim.Rel15 - -n100 -R106 -b106 - -n100 -R217 -b217 - -n100 -R273 -b273 - -n100 -R106 -o12 - -n100 -R217 -o48 - -n100 -R106 -a25 - -n100 -R106 -a51 - -n100 -R217 -b100 - -n100 -R217 -a80 - -n100 -R217 -a110 -b100 - -n100 -e28 - nr_dlsim.test1 nr_dlsim.test2 nr_dlsim.test3 nr_dlsim.test4 nr_dlsim.test5 nr_dlsim.test6 nr_dlsim.test7 nr_dlsim.test8 nr_dlsim.test9 nr_dlsim.test10 nr_dlsim.test11 + + -n100 -R106 -b106 -s5 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -R217 -b217 -s5 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -R273 -b273 -s5 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -R106 -o12 -s5 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -R217 -o48 -s5 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -R106 -a25 -s5 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -R106 -a51 -s5 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -R217 -b100 -s5 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -R217 -a80 -s5 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -R217 -a110 -s5 -b100 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -e28 -s20 -s5 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -e16 -s10 -s5 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + + nr_dlsim.test1 nr_dlsim.test2 nr_dlsim.test3 nr_dlsim.test4 nr_dlsim.test5 nr_dlsim.test6 nr_dlsim.test7 nr_dlsim.test8 nr_dlsim.test9 nr_dlsim.test10 nr_dlsim.test11 nr_dlsim.test12 PDSCH test OK segmentation fault|assertion|exiting|fatal 3 diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 737bd4d1ff..177640bacc 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -546,7 +546,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, //LOG_E(PHY,"AbsSubframe %d.%d Start LDPC segment %d/%d A %d ",frame%1024,nr_tti_rx,r,harq_process->C-1, A); - printf("harq process dr iteration %d\n", p_decParams->numMaxIter); + //printf("harq process dr iteration %d\n", p_decParams->numMaxIter); memset(pv,0,2*harq_process->Z*sizeof(int16_t)); //memset(pl,0,2*p_decParams->Z*sizeof(int8_t)); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 19709cf148..cd19643bc4 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -408,8 +408,8 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) for(uint8_t symbol = symbol_start; symbol < symbol_end; symbol++) { nr_rx_pusch(gNB, ULSCH_id, frame_rx, slot_rx, symbol, harq_pid); } - //LOG_M("rxdataF_comp.m","rxF_comp",gNB->pusch_vars[0]->rxdataF_comp[0],6900,1,1); - //LOG_M("rxdataF_ext.m","rxF_ext",gNB->pusch_vars[0]->rxdataF_ext[0],6900,1,1); + LOG_M("rxdataF_comp.m","rxF_comp",gNB->pusch_vars[0]->rxdataF_comp[0],6900,1,1); + LOG_M("rxdataF_ext.m","rxF_ext",gNB->pusch_vars[0]->rxdataF_ext[0],6900,1,1); nr_ulsch_procedures(gNB, frame_rx, slot_rx, ULSCH_id, harq_pid); nr_fill_rx_indication(gNB, frame_rx, slot_rx, ULSCH_id, harq_pid); // indicate SDU to MAC nr_fill_crc_indication(gNB, frame_rx, slot_rx, ULSCH_id, 0); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 5ce6f9e420..6ffb7d7e50 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -229,17 +229,18 @@ int main(int argc, char **argv) int mcsIndex_set=0,rbStart_set=0,rbSize_set=0; int print_perf = 0; + FILE *scg_fd=NULL; + while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:s:S:t:x:y:z:M:N:F:GR:dPIL:Ea:b:e:m:")) != -1) { switch (c) { - /*case 'f': - write_output_file=1; - output_fd = fopen(optarg,"w"); + case 'f': + scg_fd = fopen(optarg,"r"); - if (output_fd==NULL) { + if (scg_fd==NULL) { printf("Error opening %s\n",optarg); exit(-1); } - break;*/ + break; /*case 'd': frame_type = 1; @@ -429,7 +430,7 @@ int main(int argc, char **argv) printf("-O oversampling factor (1,2,4,8,16)\n"); printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); - //printf("-f Output filename (.txt format) for Pe/SNR results\n"); + printf("-f raw file containing RRC configuration (generated by gNB)\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); printf("-E used CSS scheduler\n"); printf("-o CORESET offset\n"); @@ -470,8 +471,8 @@ int main(int argc, char **argv) gNB_mac = RC.nrmac[0]; gNB_RRC_INST rrc; memset((void*)&rrc,0,sizeof(rrc)); + // read in SCGroupConfig - FILE *scg_fd = fopen("reconfig.raw","r"); AssertFatal(scg_fd != NULL,"no reconfig.raw file\n"); char buffer[1024]; int msg_len=fread(buffer,1,1024,scg_fd); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index dddddec465..5f2351968c 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -52,7 +52,6 @@ #include "openair1/SIMULATION/TOOLS/sim.h" #include "openair1/SIMULATION/RF/rf.h" #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" -#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" #include "openair2/LAYER2/NR_MAC_UE/mac_proto.h" #include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" @@ -63,6 +62,7 @@ PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; +int sf_ahead=4, phy_test = 0; double cpuf; uint8_t nfapi_mode = 0; uint16_t NB_UE_INST = 1; @@ -116,7 +116,10 @@ int generate_dlsch_header(unsigned char *mac_header, uint64_t get_softmodem_optmask(void) {return 0;} int rlc_module_init (int enb) {return(0);} void pdcp_layer_init (void) {} +void pdcp_run (const protocol_ctxt_t *const ctxt_pP) { return;} void nr_ip_over_LTE_DRB_preconfiguration(void){} +int rrc_init_nr_global_param(void){return(0);} + // needed for some functions uint16_t n_rnti = 0x1234; @@ -166,6 +169,7 @@ int main(int argc, char **argv) UE_nr_rxtx_proc_t UE_proc; + FILE *scg_fd=NULL; if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0 ) { @@ -175,7 +179,7 @@ int main(int argc, char **argv) //logInit(); randominit(0); - while ((c = getopt(argc, argv, "d:f:g:h:i:j:l:m:n:p:r:s:y:z:F:M:N:P:R:S:L:")) != -1) { + while ((c = getopt(argc, argv, "d:f:g:h:i:j:l:m:n:p:r:s:y:z:F:G:M:N:P:R:S:L:")) != -1) { switch (c) { /*case 'd': @@ -190,16 +194,15 @@ int main(int argc, char **argv) number_of_frames = atoi(optarg); break; - /*case 'f': - write_output_file = 1; - output_fd = fopen(optarg, "w"); + case 'G': + scg_fd = fopen(optarg, "r"); - if (output_fd == NULL) { + if (scg_fd == NULL) { printf("Error opening %s\n", optarg); exit(-1); } - break;*/ + break; case 'g': switch ((char) *optarg) { @@ -356,10 +359,10 @@ int main(int argc, char **argv) //printf("-x Transmission mode (1,2,6 for the moment)\n"); printf("-y Number of TX antennas used in eNB\n"); printf("-z Number of RX antennas used in UE\n"); - printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); + printf("-G raw file containing RRC configuration (generated by gNB)\n"); printf("-M Multiple SSB positions in burst\n"); printf("-N Nid_cell\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); @@ -403,12 +406,74 @@ int main(int argc, char **argv) frame_parms->N_RB_UL = N_RB_UL; frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL; - crcTableInit(); + RC.nb_nr_macrlc_inst = 1; + RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int)); + for (i = 0; i < RC.nb_nr_macrlc_inst; i++) + RC.nb_nr_mac_CC[i] = 1; + mac_top_init_gNB(); + gNB_MAC_INST* gNB_mac = RC.nrmac[0]; + gNB_RRC_INST rrc; + memset((void*)&rrc,0,sizeof(rrc)); - nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_UL, mu, Nid_cell, SSB_positions); + // read in SCGroupConfig + AssertFatal(scg_fd != NULL,"no reconfig.raw file\n"); + char buffer[1024]; + int msg_len=fread(buffer,1,1024,scg_fd); + NR_RRCReconfiguration_t *NR_RRCReconfiguration; - phy_init_nr_gNB(gNB, 0, 0); - //init_eNB_afterRU(); + printf("Decoding NR_RRCReconfiguration (%d bytes)\n",msg_len); + asn_dec_rval_t dec_rval = uper_decode_complete( NULL, + &asn_DEF_NR_RRCReconfiguration, + (void **)&NR_RRCReconfiguration, + (uint8_t *)buffer, + msg_len); + + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { + AssertFatal(1==0,"NR_RRCReConfiguration decode error\n"); + // free the memory + SEQUENCE_free( &asn_DEF_NR_RRCReconfiguration, NR_RRCReconfiguration, 1 ); + exit(-1); + } + fclose(scg_fd); + + AssertFatal(NR_RRCReconfiguration->criticalExtensions.present == NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration,"wrong NR_RRCReconfiguration->criticalExstions.present type\n"); + + NR_RRCReconfiguration_IEs_t *reconfig_ies = NR_RRCReconfiguration->criticalExtensions.choice.rrcReconfiguration; + NR_CellGroupConfig_t *secondaryCellGroup; + dec_rval = uper_decode_complete( NULL, + &asn_DEF_NR_CellGroupConfig, + (void **)&secondaryCellGroup, + (uint8_t *)reconfig_ies->secondaryCellGroup->buf, + reconfig_ies->secondaryCellGroup->size); + + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { + AssertFatal(1==0,"NR_CellGroupConfig decode error\n"); + // free the memory + SEQUENCE_free( &asn_DEF_NR_CellGroupConfig, secondaryCellGroup, 1 ); + exit(-1); + } + + NR_ServingCellConfigCommon_t *scc = secondaryCellGroup->spCellConfig->reconfigurationWithSync->spCellConfigCommon; + + xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup); + + rrc.carrier.servingcellconfigcommon = secondaryCellGroup->spCellConfig->reconfigurationWithSync->spCellConfigCommon; + printf("%p,%p\n", + secondaryCellGroup->spCellConfig->reconfigurationWithSync->spCellConfigCommon, + rrc.carrier.servingcellconfigcommon); + + AssertFatal((gNB->if_inst = NR_IF_Module_init(0))!=NULL,"Cannot register interface"); + gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; + // common configuration + rrc_mac_config_req_gNB(0,0,1,scc,0,0,NULL); + // UE dedicated configuration + rrc_mac_config_req_gNB(0,0,1,NULL,1,secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); + phy_init_nr_gNB(gNB,0,0); + N_RB_DL = gNB->frame_parms.N_RB_DL; + + //crcTableInit(); + + //nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_UL, mu, Nid_cell, SSB_positions); frame_length_complex_samples = frame_parms->samples_per_subframe; frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP; @@ -428,7 +493,9 @@ int main(int argc, char **argv) } //nr_init_frame_parms_ue(&UE->frame_parms); - //init_nr_ue_transport(UE, 0); + init_nr_ue_transport(UE, 0); + + /* for (sf = 0; sf < 2; sf++) { for (i = 0; i < 2; i++) { @@ -441,6 +508,27 @@ int main(int argc, char **argv) } } + */ + + nr_l2_init_ue(NULL); + NR_UE_MAC_INST_t* UE_mac = get_mac_inst(0); + + UE->if_inst = nr_ue_if_module_init(0); + UE->if_inst->scheduled_response = nr_ue_scheduled_response; + UE->if_inst->phy_config_request = nr_ue_phy_config_request; + UE->if_inst->dl_indication = nr_ue_dl_indication; + UE->if_inst->ul_indication = nr_ue_ul_indication; + + UE_mac->if_module = nr_ue_if_module_init(0); + + //Configure UE + rrc.carrier.MIB = (uint8_t*) malloc(4); + rrc.carrier.sizeof_MIB = do_MIB_NR(&rrc,0); + + nr_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib,secondaryCellGroup->spCellConfig); + + nr_ue_phy_config_request(&UE_mac->phy_config); + unsigned char harq_pid = 0; @@ -681,7 +769,7 @@ int main(int argc, char **argv) break; } // frame loop - if(is_frame_in_error == 0) + if(is_frame_in_error == 1) break; } // SNR loop diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 412fcf09e3..677a27fb3d 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -57,7 +57,7 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd void ue_dci_configuration(NR_UE_MAC_INST_t *mac,fapi_nr_dl_config_request_t *dl_config,int frame,int slot) { // check if DL slot - if (is_nr_DL_slot(mac->scc->tdd_UL_DL_ConfigurationCommon,slot)==1) { + if (is_nr_DL_slot(mac->scc,slot)==1) { // get BWP 1, Coreset 0, SearchSpace 0 if (mac->DLbwp[0]==NULL) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 3e57953082..8f29aa56a3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -505,7 +505,6 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs]; mac_rlc_status_resp_t rlc_status; - nfapi_nr_config_request_t *cfg = &gNB_mac->config[0]; NR_UE_list_t *UE_list = &gNB_mac->UE_list; @@ -835,4 +834,4 @@ void nr_schedule_uss_ulsch_phytest(int Mod_idP, pdcch_pdu_rel15->PayloadSizeBits[0]=nr_dci_size(dci_formats[0],rnti_types[0],pdcch_pdu_rel15->BWPSize); fill_dci_pdu_rel15(pdcch_pdu_rel15,&dci_pdu_rel15[0],dci_formats,rnti_types); -} \ No newline at end of file +} diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 5a04909e5f..4ae679b8f5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -69,4 +69,4 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, if (sduP != NULL) UE_scheduling_control->ta_update = timing_advance; } -} \ No newline at end of file +} diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index cbf36f8856..5bc320d5e2 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -112,7 +112,7 @@ typedef struct { DLSCH_PDU DLSCH_pdu[4][MAX_MOBILES_PER_GNB]; /// scheduling control info - NR_UE_sched_ctrl_t UE_sched_ctrl[MAX_MOBILES_PER_GNB]; + UE_sched_ctrl_t UE_sched_ctrl[MAX_MOBILES_PER_GNB]; int next[MAX_MOBILES_PER_GNB]; int head; int next_ul[MAX_MOBILES_PER_GNB]; From 16d8248c8b6fc42116d2df0a1e659b82248b4eaf Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 5 Feb 2020 15:09:32 +0100 Subject: [PATCH 2/4] removing logs --- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 8c6e8c7f18..9e17251088 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -414,8 +414,8 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) for(uint8_t symbol = symbol_start; symbol < symbol_end; symbol++) { nr_rx_pusch(gNB, ULSCH_id, frame_rx, slot_rx, symbol, harq_pid); } - LOG_M("rxdataF_comp.m","rxF_comp",gNB->pusch_vars[0]->rxdataF_comp[0],6900,1,1); - LOG_M("rxdataF_ext.m","rxF_ext",gNB->pusch_vars[0]->rxdataF_ext[0],6900,1,1); + //LOG_M("rxdataF_comp.m","rxF_comp",gNB->pusch_vars[0]->rxdataF_comp[0],6900,1,1); + //LOG_M("rxdataF_ext.m","rxF_ext",gNB->pusch_vars[0]->rxdataF_ext[0],6900,1,1); nr_ulsch_procedures(gNB, frame_rx, slot_rx, ULSCH_id, harq_pid); nr_fill_rx_indication(gNB, frame_rx, slot_rx, ULSCH_id, harq_pid); // indicate SDU to MAC nr_fill_crc_indication(gNB, frame_rx, slot_rx, ULSCH_id, 0); From e4d8dd1e66721a0c28614101502389bf33aeea8e Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 5 Feb 2020 22:57:24 +0100 Subject: [PATCH 3/4] ulsim working again. added error count and adapted test_case_list --- cmake_targets/autotests/test_case_list.xml | 10 +-- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 39 +++++---- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 4 +- openair1/SIMULATION/NR_PHY/ulsim.c | 83 +++++++++---------- 4 files changed, 64 insertions(+), 72 deletions(-) diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index eea6c037ae..5227ed010e 100644 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1253,11 +1253,11 @@ $OPENAIR_DIR/cmake_targets/autotests/tools/free_mem.bash $OPENAIR_DIR/targets/bin/nr_ulsim.Rel15 - -f100 -m9 -r106 -s10 - -f100 -m16 -s20 - -f100 -m28 -s30 - -f100 -m9 -R217 -r217 -s10 - -f100 -m9 -R273 -r273 -s10 + -n100 -m9 -r106 -s0 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -m16 -s10 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -m28 -s20 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -m9 -R217 -r217 -s0 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw + -n100 -m9 -R273 -r273 -s0 -f $OPENAIR_DIR/ci-scripts/rrc-files/reconfig.raw nr_ulsim.test1 nr_ulsim.test2 nr_ulsim.test3 nr_ulsim.test4 nr_ulsim.test5 PUSCH test OK segmentation fault|assertion|exiting|fatal diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index a0fb8d7ed6..872342cd5b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -684,7 +684,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, } harq_process->handled = 1; - return (ulsch->max_ldpc_iterations + 1); + ret = ulsch->max_ldpc_iterations + 1; } else { @@ -705,29 +705,28 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, { LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d (pid %d, round %d, TBS %d)\n",phy_vars_gNB->Mod_id,nr_tti_rx,harq_pid,harq_process->round,harq_process->TBS); } - } - - // Reassembly of Transport block here - offset = 0; - Kr = harq_process->K; - Kr_bytes = Kr>>3; - - for (r=0; rC; r++) { - - memcpy(harq_process->b+offset, - harq_process->c[r], - Kr_bytes- - (harq_process->F>>3) -((harq_process->C>1)?3:0)); - - offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0)); + // Reassembly of Transport block here + offset = 0; + Kr = harq_process->K; + Kr_bytes = Kr>>3; + + for (r=0; rC; r++) { + + memcpy(harq_process->b+offset, + harq_process->c[r], + Kr_bytes- - (harq_process->F>>3) -((harq_process->C>1)?3:0)); + + offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0)); + #ifdef DEBUG_ULSCH_DECODING - printf("Segment %u : Kr = %u bytes\n", r, Kr_bytes); - printf("copied %d bytes to b sequence (harq_pid %d)\n", (Kr_bytes - (harq_process->F>>3)-((harq_process->C>1)?3:0)), harq_pid); - printf("b[0] = %x, c[%d] = %x\n", harq_process->b[offset], harq_process->F>>3, harq_process->c[r]); + printf("Segment %u : Kr = %u bytes\n", r, Kr_bytes); + printf("copied %d bytes to b sequence (harq_pid %d)\n", (Kr_bytes - (harq_process->F>>3)-((harq_process->C>1)?3:0)), harq_pid); + printf("b[0] = %x, c[%d] = %x\n", harq_process->b[offset], harq_process->F>>3, harq_process->c[r]); #endif - + + } } - ulsch->last_iteration_cnt = ret; return(ret); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 9e17251088..f9c154ea29 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -279,9 +279,9 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH 0); if (ret > gNB->ulsch[ULSCH_id][0]->max_ldpc_iterations) - LOG_I(PHY, "ULSCH in error\n"); + LOG_I(PHY, "ULSCH %d in error\n",ULSCH_id); else - LOG_I(PHY, "ULSCH received ok\n"); + LOG_I(PHY, "ULSCH %d received ok\n",ULSCH_id); } diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 5f2351968c..2c397090ba 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -131,9 +131,9 @@ int main(int argc, char **argv) int i,sf; double SNR, snr0 = -2.0, snr1 = 2.0; double sigma, sigma_dB; - double snr_step = 0.1; + double snr_step = 1; uint8_t snr1set = 0; - int slot = 0; + int slot = 0, frame = 0; FILE *output_fd = NULL; //uint8_t write_output_file = 0; int trial, n_trials = 1, n_errors = 0, n_false_positive = 0, delay = 0; @@ -147,13 +147,12 @@ int main(int argc, char **argv) SCM_t channel_model = AWGN; //Rayleigh1_anticorr; uint16_t N_RB_DL = 106, N_RB_UL = 106, mu = 1; //unsigned char frame_type = 0; - int number_of_frames = 1; int frame_length_complex_samples,frame_length_complex_samples_no_prefix; NR_DL_FRAME_PARMS *frame_parms; int loglvl = OAILOG_WARNING; uint64_t SSB_positions=0x01; uint16_t nb_symb_sch = 12; - int start_symbol = 2; + int start_symbol = 0; uint16_t nb_rb = 50; uint8_t Imcs = 9; uint8_t precod_nbr_layers = 1; @@ -164,7 +163,8 @@ int main(int argc, char **argv) int32_t txlev; int start_rb = 0; int UE_id =0; // [hna] only works for UE_id = 0 because NUMBER_OF_NR_UE_MAX is set to 1 (phy_init_nr_gNB causes segmentation fault) - + float target_error_rate = 0.01; + cpuf = get_cpu_freq_GHz(); @@ -179,7 +179,7 @@ int main(int argc, char **argv) //logInit(); randominit(0); - while ((c = getopt(argc, argv, "d:f:g:h:i:j:l:m:n:p:r:s:y:z:F:G:M:N:P:R:S:L:")) != -1) { + while ((c = getopt(argc, argv, "d:f:g:h:i:j:l:m:n:p:r:s:y:z:F:M:N:P:R:S:L:")) != -1) { switch (c) { /*case 'd': @@ -191,10 +191,6 @@ int main(int argc, char **argv) break; case 'f': - number_of_frames = atoi(optarg); - break; - - case 'G': scg_fd = fopen(optarg, "r"); if (scg_fd == NULL) { @@ -505,7 +501,6 @@ int main(int argc, char **argv) printf("Can't get ue ulsch structures\n"); exit(-1); } - } } */ @@ -543,7 +538,6 @@ int main(int argc, char **argv) unsigned char *test_input_bit; uint32_t errors_decoding = 0; uint32_t errors_scrambling = 0; - uint32_t is_frame_in_error = 0; test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); @@ -581,13 +575,6 @@ int main(int argc, char **argv) for (SNR = snr0; SNR < snr1; SNR += snr_step) { - printf("-------------------\n"); - printf("SNR %f\n", SNR); - printf("-------------------\n"); - - is_frame_in_error = 0; - for (int frame = 0; frame < number_of_frames; frame++) { - UE_proc.nr_tti_tx = slot; UE_proc.frame_tx = frame; @@ -677,7 +664,7 @@ int main(int argc, char **argv) phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, 0); - if (number_of_frames==1) + if (n_trials==1) LOG_M("txsig0.m","txs0", UE->common_vars.txdata[0],frame_length_complex_samples,1,1); /////////// @@ -717,12 +704,16 @@ int main(int argc, char **argv) //---------------------------------------------------------- phy_procedures_gNB_common_RX(gNB, frame, slot); - if (number_of_frames==1) + if (n_trials==1) LOG_M("rxsigF0.m","rxsF0",gNB->common_vars.rxdataF[0],frame_length_complex_samples_no_prefix,1,1); phy_procedures_gNB_uespec_RX(gNB, frame, slot); //////////////////////////////////////////////////////////// + if (gNB->ulsch[0][0]->last_iteration_cnt >= + gNB->ulsch[0][0]->max_ldpc_iterations+1) + n_errors++; + //---------------------------------------------------------- //----------------- count and print errors ----------------- //---------------------------------------------------------- @@ -732,14 +723,15 @@ int main(int argc, char **argv) if(((ulsch_ue[0]->g[i] == 0) && (gNB->pusch_vars[UE_id]->llr[i] <= 0)) || ((ulsch_ue[0]->g[i] == 1) && (gNB->pusch_vars[UE_id]->llr[i] >= 0))) { - if(errors_scrambling == 0) - printf("\x1B[34m" "[frame %d][trial %d]\t1st bit in error in unscrambling = %d\n" "\x1B[0m", frame, trial, i); + /*if(errors_scrambling == 0) + printf("\x1B[34m" "[frame %d][trial %d]\t1st bit in error in unscrambling = %d\n" "\x1B[0m", frame, trial, i);*/ errors_scrambling++; } } if (errors_scrambling > 0) { - printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in unscrambling = %d\n" "\x1B[0m", frame, trial, errors_scrambling); + if (n_trials==1) + printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in unscrambling = %d\n" "\x1B[0m", frame, trial, errors_scrambling); } for (i = 0; i < TBS; i++) { @@ -748,38 +740,39 @@ int main(int argc, char **argv) test_input_bit[i] = (ulsch_ue[0]->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7); if (estimated_output_bit[i] != test_input_bit[i]) { - if(errors_decoding == 0) - printf("\x1B[34m""[frame %d][trial %d]\t1st bit in error in decoding = %d\n" "\x1B[0m", frame, trial, i); + /*if(errors_decoding == 0) + printf("\x1B[34m""[frame %d][trial %d]\t1st bit in error in decoding = %d\n" "\x1B[0m", frame, trial, i);*/ errors_decoding++; } } if (errors_decoding > 0) { - is_frame_in_error = 1; n_false_positive++; - printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in decoding = %d\n" "\x1B[0m", frame, trial, errors_decoding); - } else { - is_frame_in_error = 0; - break; - } - //////////////////////////////////////////////////////////// + if (n_trials==1) + printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in decoding = %d\n" "\x1B[0m", frame, trial, errors_decoding); + } + } // trial loop - if (is_frame_in_error == 1) - break; - } // frame loop + printf("*****************************************\n"); + printf("SNR %f: n_errors (negative CRC) = %d/%d, false_positive %d/%d, errors_scrambling %d/%d\n", SNR, n_errors, n_trials, n_false_positive, n_trials, errors_scrambling, n_trials); + printf("\n"); + printf("SNR %f: Channel BLER %e, Channel BER %e\n", SNR,(double)n_errors/n_trials,(double)errors_scrambling/available_bits/n_trials); + printf("*****************************************\n"); + printf("\n"); - if(is_frame_in_error == 1) - break; + if(n_trials==1) + break; + + if ((float)n_errors/(float)n_trials <= target_error_rate) { + printf("*************\n"); + printf("PUSCH test OK\n"); + printf("*************\n"); + break; + } + } // SNR loop - if(is_frame_in_error == 0) { - printf("\n"); - printf("*************\n"); - printf("PUSCH test OK\n"); - printf("*************\n"); - } - printf("\n"); free(test_input_bit); From debe10c296363c651e7bf9a522f333c948d5153d Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Thu, 6 Feb 2020 14:57:16 +0100 Subject: [PATCH 4/4] fixing a bad merge, removing a log, resetting MAX_LDPC_ITERATIONS=5 --- executables/nr-gnb.c | 2 -- openair1/PHY/CODING/coding_defs.h | 2 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 3f1b95a793..0302697e5b 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -479,8 +479,6 @@ int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot } AssertFatal((ret = pthread_mutex_lock(&ru_proc->mutex_gNBs))==0,"ERROR pthread_mutex_lock failed on mutex_gNBs L1_thread_tx with ret=%d\n",ret); - AssertFatal((ret=pthread_mutex_lock(&ru_proc->mutex_gNBs))==0,"mutex_lock returned %d\n",ret); - ru_proc->instance_cnt_gNBs = 0; ru_proc->timestamp_tx = timestamp_tx; ru_proc->tti_tx = slot_tx; diff --git a/openair1/PHY/CODING/coding_defs.h b/openair1/PHY/CODING/coding_defs.h index 00708ed60c..9b111309cd 100644 --- a/openair1/PHY/CODING/coding_defs.h +++ b/openair1/PHY/CODING/coding_defs.h @@ -38,7 +38,7 @@ #define MAX_TURBO_ITERATIONS_MBSFN 8 #define MAX_TURBO_ITERATIONS max_turbo_iterations -#define MAX_LDPC_ITERATIONS 10//5 +#define MAX_LDPC_ITERATIONS 5 #define MAX_LDPC_ITERATIONS_MBSFN 4 #define LTE_NULL 2 diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index f9c154ea29..025e92eb22 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -61,7 +61,7 @@ void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_scf_t *cfg, NR_DL_FRAME sco = cfg->ssb_table.ssb_subcarrier_offset.value; fp->ssb_start_subcarrier = (12 * cfg->ssb_table.ssb_offset_point_a.value + sco); - LOG_I(PHY, "SSB first subcarrier %d (%d,%d)\n", fp->ssb_start_subcarrier,cfg->ssb_table.ssb_offset_point_a.value,sco); + LOG_D(PHY, "SSB first subcarrier %d (%d,%d)\n", fp->ssb_start_subcarrier,cfg->ssb_table.ssb_offset_point_a.value,sco); } void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) {