diff --git a/ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf index f3cb31f449..2c2ca635a6 100644 --- a/ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf @@ -197,8 +197,8 @@ MACRLCs = ( tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; phy_test_mode = 0; - puSch10xSnr = 200; - puCch10xSnr = 200; + puSch10xSnr = 160; + puCch10xSnr = 160; } ); @@ -227,7 +227,7 @@ RUs = ( THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } diff --git a/ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf index e33daa7a8a..4dd8c1ee22 100644 --- a/ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf @@ -197,8 +197,8 @@ MACRLCs = ( tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; phy_test_mode = 0; - puSch10xSnr = 200; - puCch10xSnr = 200; + puSch10xSnr = 160; + puCch10xSnr = 160; } ); @@ -218,7 +218,7 @@ RUs = ( att_rx = 0; bands = [7]; max_pdschReferenceSignalPower = -27; - max_rxgain = 115; + max_rxgain = 125; eNB_instances = [0]; } @@ -227,7 +227,7 @@ RUs = ( THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } diff --git a/ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf index 32e8bb9931..cae47b152c 100644 --- a/ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf @@ -197,8 +197,8 @@ MACRLCs = ( tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; phy_test_mode = 0; - puSch10xSnr = 200; - puCch10xSnr = 200; + puSch10xSnr = 160; + puCch10xSnr = 160; } ); @@ -218,7 +218,7 @@ RUs = ( att_rx = 0; bands = [7]; max_pdschReferenceSignalPower = -27; - max_rxgain = 115; + max_rxgain = 120; eNB_instances = [0]; } @@ -227,7 +227,7 @@ RUs = ( THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } diff --git a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf index fc2f24b8a1..6c80a4f7cf 100644 --- a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf +++ b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf @@ -200,8 +200,8 @@ MACRLCs = ( tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; phy_test_mode = 0; - puSch10xSnr = 200; - puCch10xSnr = 200; + puSch10xSnr = 160; + puCch10xSnr = 160; } ); @@ -234,7 +234,7 @@ RUs = ( THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } diff --git a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf index 010ef28061..f4be50810c 100644 --- a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf +++ b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf @@ -200,8 +200,8 @@ MACRLCs = ( tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; phy_test_mode = 0; - puSch10xSnr = 200; - puCch10xSnr = 200; + puSch10xSnr = 160; + puCch10xSnr = 160; } ); @@ -234,7 +234,7 @@ RUs = ( THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } diff --git a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf index ddf01096cd..48c8370b4b 100644 --- a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf +++ b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf @@ -200,8 +200,8 @@ MACRLCs = ( tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; phy_test_mode = 0; - puSch10xSnr = 200; - puCch10xSnr = 200; + puSch10xSnr = 160; + puCch10xSnr = 160; } ); @@ -234,7 +234,7 @@ RUs = ( THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } diff --git a/ci-scripts/conf_files/rru.fdd.band7.conf b/ci-scripts/conf_files/rru.fdd.band7.conf index ff5e13908e..dab69e1f1e 100644 --- a/ci-scripts/conf_files/rru.fdd.band7.conf +++ b/ci-scripts/conf_files/rru.fdd.band7.conf @@ -20,7 +20,7 @@ RUs = ( THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } diff --git a/ci-scripts/main.py b/ci-scripts/main.py index 24475f7eb3..5c371a99ee 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -1504,7 +1504,8 @@ class SSHConnection(): return ENB_PROCESS_ASSERTION if foundRealTimeIssue: logging.debug('\u001B[1;37;41m eNB faced real time issues! \u001B[0m') - return ENB_PROCESS_REALTIME_ISSUE + self.htmleNBFailureMsg += 'eNB faced real time issues!\n' + #return ENB_PROCESS_REALTIME_ISSUE return 0 def TerminateeNB(self): diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index 4addd20ebe..c54c3e3322 100644 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1053,16 +1053,24 @@ execution - nr_pbchsim Test cases. (Test1: PBCH-only), - (Test2: PBCH and synchronization) + nr_pbchsim Test cases. (Test1: PBCH-only, 106 PRB), + (Test2: PBCH and synchronization, 106PBR), + (Test3: PBCH-only, 217 PRB), + (Test4: PBCH and synchronization, 217 RPB), + (Test5: PBCH-only, 217 PRB), + (Test6: PBCH and synchronization, 217 PRB) $OPENAIR_DIR/cmake_targets/build_oai --phy_simulators -c $OPENAIR_DIR/cmake_targets/autotests/tools/free_mem.bash $OPENAIR_DIR/targets/bin/nr_pbchsim.Rel15 - -s-11 -S-10 -n1000 - -s-11 -S-10 -n10 -I + -s-11 -S-10 -n1000 -R106 + -s-11 -S-10 -n10 -I -R106 + -s-11 -S-10 -n1000 -R217 -N10 + -s-11 -S-10 -n10 -I -R217 -N10 + -s-11 -S-10 -n1000 -R273 -N20 + -s-11 -S-10 -n10 -I -R273 -N20 nr_pbchsim.test1 nr_pbchsim.test2 PBCH test OK segmentation fault|assertion|exiting|fatal diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index f4b64026e1..f018e8c422 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -339,6 +339,10 @@ function main() { FORCE_DEADLINE_SCHEDULER_FLAG_USER="True" echo_info "Enabling the usage of deadline scheduler" shift 1;; + --enable-cpu-affinity) + CPU_AFFINITY_FLAG_USER="True" + echo_info "Enabling CPU Affinity (only valid when not using deadline scheduler)" + shift 1;; --disable-cpu-affinity) CPU_AFFINITY_FLAG_USER="False" echo_info "Disabling CPU Affinity (only valid when not using deadline scheduler)" diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 86dadb249a..838e52dada 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -197,10 +197,11 @@ typedef struct { } fapi_nr_rx_indication_body_t; /// +#define NFAPI_RX_IND_MAX_PDU 100 typedef struct { uint32_t sfn_slot; uint16_t number_pdus; - fapi_nr_rx_indication_body_t *rx_indication_body; + fapi_nr_rx_indication_body_t rx_indication_body[NFAPI_RX_IND_MAX_PDU]; } fapi_nr_rx_indication_t; typedef struct { diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c index 19708b3dca..6db9548dbe 100644 --- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c +++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c @@ -157,7 +157,9 @@ int test_ldpc(short No_iteration, //double code_rate_actual_vec[8] = {0.2, 0.33333, 0.4, 0.5, 0.66667, 0.73333, 0.81481, 0.88}; t_nrLDPC_dec_params decParams; - + t_nrLDPC_procBuf nrLDPC_procBuf; + t_nrLDPC_procBuf* p_nrLDPC_procBuf = &nrLDPC_procBuf; + t_nrLDPC_time_stats decoder_profiler; t_nrLDPC_time_stats* p_decoder_profiler =&decoder_profiler ; @@ -210,6 +212,9 @@ int test_ldpc(short No_iteration, reset_meas(&decoder_profiler.llr2bit); //reset_meas(&decoder_profiler.total); + // Allocate LDPC decoder buffers + p_nrLDPC_procBuf = nrLDPC_init_mem(); + for (j=0;jnumBnInBnGroups; const uint32_t* lut_startAddrBnGroups = p_lut->startAddrBnGroups; const uint16_t* lut_startAddrBnGroupsLlr = p_lut->startAddrBnGroupsLlr; + int8_t* bnProcBuf = p_procBuf->bnProcBuf; + int8_t* bnProcBufRes = p_procBuf->bnProcBufRes; + int8_t* llrRes = p_procBuf->llrRes; + int8_t* llrProcBuf = p_procBuf->llrProcBuf; + __m128i* p_bnProcBuf; __m256i* p_bnProcBufRes; __m128i* p_llrProcBuf; @@ -1676,7 +1681,7 @@ static inline void nrLDPC_bnProcPc(t_nrLDPC_lut* p_lut, uint16_t Z) \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_bnProc(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline void nrLDPC_bnProc(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { // BN Processing calculating the values to send back to the CNs for next iteration // bnProcBufRes contains the sum of all edges to each BN at the start of each group @@ -1685,6 +1690,10 @@ static inline void nrLDPC_bnProc(t_nrLDPC_lut* p_lut, uint16_t Z) const uint32_t* lut_startAddrBnGroups = p_lut->startAddrBnGroups; const uint16_t* lut_startAddrBnGroupsLlr = p_lut->startAddrBnGroupsLlr; + int8_t* bnProcBuf = p_procBuf->bnProcBuf; + int8_t* bnProcBufRes = p_procBuf->bnProcBufRes; + int8_t* llrRes = p_procBuf->llrRes; + __m256i* p_bnProcBuf; __m256i* p_bnProcBufRes; __m256i* p_llrRes; diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h index 300624ae76..5b96d6226e 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h @@ -36,11 +36,14 @@ \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_cnProc_BG2(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline void nrLDPC_cnProc_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBuf = p_procBuf->cnProcBuf; + int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; + __m256i* p_cnProcBuf; __m256i* p_cnProcBufRes; @@ -362,11 +365,14 @@ static inline void nrLDPC_cnProc_BG2(t_nrLDPC_lut* p_lut, uint16_t Z) \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_cnProc_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline void nrLDPC_cnProc_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBuf = p_procBuf->cnProcBuf; + int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; + __m256i* p_cnProcBuf; __m256i* p_cnProcBufRes; @@ -858,11 +864,14 @@ static inline void nrLDPC_cnProc_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) \param Z Lifting size \return 32-bit parity check indicator */ -static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBuf = p_procBuf->cnProcBuf; + int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; + __m256i* p_cnProcBuf; __m256i* p_cnProcBufRes; @@ -1490,11 +1499,14 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) \param Z Lifting size \return 32-bit parity check indicator */ -static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBuf = p_procBuf->cnProcBuf; + int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; + __m256i* p_cnProcBuf; __m256i* p_cnProcBufRes; diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c index fbdb9a3fa4..bbcd34c368 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c @@ -45,20 +45,22 @@ #include "nrLDPC_tools/nrLDPC_debug.h" #endif -static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler); +static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDPC_procBuf* p_procBuf, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler); -int32_t nrLDPC_decoder(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out, t_nrLDPC_time_stats* p_profiler) +int32_t nrLDPC_decoder(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out, t_nrLDPC_procBuf* p_procBuf, t_nrLDPC_time_stats* p_profiler) { uint32_t numLLR; uint32_t numIter = 0; t_nrLDPC_lut lut; t_nrLDPC_lut* p_lut = &lut; + printf("p_procBuf->cnProcBuf = %p\n", p_procBuf->cnProcBuf); + // Initialize decoder core(s) with correct LUTs numLLR = nrLDPC_init(p_decParams, p_lut); // Launch LDPC decoder core for one segment - numIter = nrLDPC_decoder_core(p_llr, p_out, numLLR, p_lut, p_decParams, p_profiler); + numIter = nrLDPC_decoder_core(p_llr, p_out, p_procBuf, numLLR, p_lut, p_decParams, p_profiler); return numIter; } @@ -72,7 +74,7 @@ int32_t nrLDPC_decoder(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* \param p_decParams LDPC decoder parameters \param p_profiler LDPC profiler statistics */ -static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler) +static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDPC_procBuf* p_procBuf, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler) { uint16_t Z = p_decParams->Z; uint8_t BG = p_decParams->BG; @@ -93,7 +95,7 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ else { // Use LLR processing buffer as temporary output buffer - p_llrOut = (int8_t*) llrProcBuf; + p_llrOut = p_procBuf->llrProcBuf; } @@ -101,27 +103,27 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->llr2llrProcBuf); #endif - nrLDPC_llr2llrProcBuf(p_lut, p_llr, Z, BG); + nrLDPC_llr2llrProcBuf(p_lut, p_llr, p_procBuf, Z, BG); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->llr2llrProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_LLR_PROC); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_PROC, p_procBuf); #endif #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->llr2CnProcBuf); #endif - nrLDPC_llr2CnProcBuf(p_lut, p_llr, numLLR, Z, BG); + nrLDPC_llr2CnProcBuf(p_lut, p_llr, p_procBuf, numLLR, Z, BG); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->llr2CnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_CN_PROC); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, p_procBuf); #endif // First iteration @@ -132,11 +134,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_cnProc_BG1(p_lut, Z); + nrLDPC_cnProc_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_cnProc_BG2(p_lut, Z); + nrLDPC_cnProc_BG2(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cnProc); @@ -144,7 +146,7 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_CN_PROC_RES); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES, p_procBuf); #endif #ifdef NR_LDPC_PROFILER_DETAIL @@ -152,11 +154,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_cn2bnProcBuf_BG1(p_lut, Z); + nrLDPC_cn2bnProcBuf_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_cn2bnProcBuf(p_lut, Z); + nrLDPC_cn2bnProcBuf(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cn2bnProcBuf); @@ -164,34 +166,34 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_BN_PROC); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC, p_procBuf); #endif // BN processing #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProcPc); #endif - nrLDPC_bnProcPc(p_lut, Z); + nrLDPC_bnProcPc(p_lut, p_procBuf, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProcPc); #endif #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_LLR_RES); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES, p_procBuf); #endif #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProc); #endif - nrLDPC_bnProc(p_lut, Z); + nrLDPC_bnProc(p_lut, p_procBuf, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProc); #endif #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_BN_PROC_RES); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES, p_procBuf); #endif // BN results to CN processing buffer @@ -200,18 +202,18 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_bn2cnProcBuf_BG1(p_lut, Z); + nrLDPC_bn2cnProcBuf_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_bn2cnProcBuf(p_lut, Z); + nrLDPC_bn2cnProcBuf(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bn2cnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, p_procBuf); #endif // Parity Check not necessary here since it will fail @@ -231,18 +233,18 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_cnProc_BG1(p_lut, Z); + nrLDPC_cnProc_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_cnProc_BG2(p_lut, Z); + nrLDPC_cnProc_BG2(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cnProc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES, p_procBuf); #endif // Send CN results back to BNs @@ -251,43 +253,43 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_cn2bnProcBuf_BG1(p_lut, Z); + nrLDPC_cn2bnProcBuf_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_cn2bnProcBuf(p_lut, Z); + nrLDPC_cn2bnProcBuf(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cn2bnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC, p_procBuf); #endif // BN Processing #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProcPc); #endif - nrLDPC_bnProcPc(p_lut, Z); + nrLDPC_bnProcPc(p_lut, p_procBuf, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProcPc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES, p_procBuf); #endif #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProc); #endif - nrLDPC_bnProc(p_lut, Z); + nrLDPC_bnProc(p_lut, p_procBuf, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES, p_procBuf); #endif // BN results to CN processing buffer @@ -296,18 +298,18 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_bn2cnProcBuf_BG1(p_lut, Z); + nrLDPC_bn2cnProcBuf_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_bn2cnProcBuf(p_lut, Z); + nrLDPC_bn2cnProcBuf(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bn2cnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, p_procBuf); #endif // Parity Check @@ -317,11 +319,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - pcRes = nrLDPC_cnProcPc_BG1(p_lut, Z); + pcRes = nrLDPC_cnProcPc_BG1(p_lut, p_procBuf, Z); } else { - pcRes = nrLDPC_cnProcPc_BG2(p_lut, Z); + pcRes = nrLDPC_cnProcPc_BG2(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cnProcPc); @@ -342,18 +344,18 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_cnProc_BG1(p_lut, Z); + nrLDPC_cnProc_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_cnProc_BG2(p_lut, Z); + nrLDPC_cnProc_BG2(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cnProc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES, p_procBuf); #endif // Send CN results back to BNs @@ -362,31 +364,31 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_cn2bnProcBuf_BG1(p_lut, Z); + nrLDPC_cn2bnProcBuf_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_cn2bnProcBuf(p_lut, Z); + nrLDPC_cn2bnProcBuf(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cn2bnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC, p_procBuf); #endif // BN Processing #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProcPc); #endif - nrLDPC_bnProcPc(p_lut, Z); + nrLDPC_bnProcPc(p_lut, p_procBuf, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProcPc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES, p_procBuf); #endif // If parity check not enabled, no need to send the BN proc results @@ -395,13 +397,13 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProc); #endif - nrLDPC_bnProc(p_lut, Z); + nrLDPC_bnProc(p_lut, p_procBuf, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES, p_procBuf); #endif // BN results to CN processing buffer @@ -410,18 +412,18 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_bn2cnProcBuf_BG1(p_lut, Z); + nrLDPC_bn2cnProcBuf_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_bn2cnProcBuf(p_lut, Z); + nrLDPC_bn2cnProcBuf(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bn2cnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, p_procBuf); #endif // Parity Check @@ -430,11 +432,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - pcRes = nrLDPC_cnProcPc_BG1(p_lut, Z); + pcRes = nrLDPC_cnProcPc_BG1(p_lut, p_procBuf, Z); } else { - pcRes = nrLDPC_cnProcPc_BG2(p_lut, Z); + pcRes = nrLDPC_cnProcPc_BG2(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cnProcPc); @@ -454,7 +456,7 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->llrRes2llrOut); #endif - nrLDPC_llrRes2llrOut(p_lut, p_llrOut, numLLR); + nrLDPC_llrRes2llrOut(p_lut, p_llrOut, p_procBuf, numLLR); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->llrRes2llrOut); #endif diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h index e1dff38723..4d2401db83 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h @@ -32,6 +32,7 @@ #define __NR_LDPC_DECODER__H__ #include "nrLDPC_types.h" +#include "nrLDPC_init_mem.h" /** \brief LDPC decoder @@ -40,6 +41,6 @@ \param p_llrOut Output vector \param p_profiler LDPC profiler statistics */ -int32_t nrLDPC_decoder(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_llrOut, t_nrLDPC_time_stats* p_profiler); +int32_t nrLDPC_decoder(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_llrOut, t_nrLDPC_procBuf* p_procBuf, t_nrLDPC_time_stats* p_profiler); #endif diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h index 6dbd38e681..940d842550 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h @@ -100,23 +100,7 @@ #define NR_LDPC_MAX_NUM_LLR 26112 // ============================================================================== -// GLOBAL VARIABLES - -// Aligned on 32 bytes = 256 bits for AVX2 -/** CN processing buffer */ -static int8_t cnProcBuf [NR_LDPC_SIZE_CN_PROC_BUF] __attribute__ ((aligned(32))); -/** Buffer for CN processing results */ -static int8_t cnProcBufRes[NR_LDPC_SIZE_CN_PROC_BUF] __attribute__ ((aligned(32))); - -/** BN processing buffer */ -static int8_t bnProcBuf [NR_LDPC_SIZE_BN_PROC_BUF] __attribute__ ((aligned(32))); -/** Buffer for BN processing results */ -static int8_t bnProcBufRes[NR_LDPC_SIZE_BN_PROC_BUF] __attribute__ ((aligned(32))); - -/** Buffer for LLR results */ -static int8_t llrRes [NR_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); -/** LLR processing buffer */ -static int8_t llrProcBuf[NR_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); +// GLOBAL CONSTANT VARIABLES /** Start addresses for the cnProcBuf for each CN group in BG1*/ static const uint32_t lut_startAddrCnGroups_BG1[NR_LDPC_NUM_CN_GROUPS_BG1] = {0, 1152, 8832, 43392, 61824, 75264, 81408, 88320, 92160}; diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h new file mode 100644 index 0000000000..bdaa118e1f --- /dev/null +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h @@ -0,0 +1,86 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*!\file nrLDPC_init_mem.h + * \brief Defines the function to initialize the LDPC decoder and sets correct LUTs. + * \author Sebastian Wagner (TCL Communications) Email: + * \date 07-12-2018 + * \version 1.0 + * \note + * \warning + */ + +#ifndef __NR_LDPC_INIT_MEM__H__ +#define __NR_LDPC_INIT_MEM__H__ + +#include +#include "nrLDPC_defs.h" +#include "nrLDPC_types.h" + +#ifndef malloc32_clear +/** + \brief Allocates 32 byte aligned memory and initializes to zero + \param size Input size in bytes + \return Pointer to memory +*/ +static inline void* malloc32_clear(size_t size) +{ + void* ptr = (void*) memalign(32, size+32); + memset(ptr, 0, size); + return ptr; +} +#endif + +/** + \brief Allocates and initializes the internal decoder processing buffers + \param p_decParams Pointer to decoder parameters + \param p_lut Pointer to decoder LUTs + \return Number of LLR values +*/ +static inline t_nrLDPC_procBuf* nrLDPC_init_mem(void) +{ + t_nrLDPC_procBuf* p_procBuf = (t_nrLDPC_procBuf*) malloc32_clear(sizeof(t_nrLDPC_procBuf)); + + if (p_procBuf) + { + p_procBuf->cnProcBuf = (int8_t*) malloc32_clear(NR_LDPC_SIZE_CN_PROC_BUF*sizeof(int8_t)); + p_procBuf->cnProcBufRes = (int8_t*) malloc32_clear(NR_LDPC_SIZE_CN_PROC_BUF*sizeof(int8_t)); + p_procBuf->bnProcBuf = (int8_t*) malloc32_clear(NR_LDPC_SIZE_BN_PROC_BUF*sizeof(int8_t)); + p_procBuf->bnProcBufRes = (int8_t*) malloc32_clear(NR_LDPC_SIZE_BN_PROC_BUF*sizeof(int8_t)); + p_procBuf->llrRes = (int8_t*) malloc32_clear(NR_LDPC_MAX_NUM_LLR *sizeof(int8_t)); + p_procBuf->llrProcBuf = (int8_t*) malloc32_clear(NR_LDPC_MAX_NUM_LLR *sizeof(int8_t)); + } + + return(p_procBuf); +} + +static inline void nrLDPC_free_mem(t_nrLDPC_procBuf* p_procBuf) +{ + free(p_procBuf->cnProcBuf); + free(p_procBuf->cnProcBufRes); + free(p_procBuf->bnProcBuf); + free(p_procBuf->bnProcBufRes); + free(p_procBuf->llrRes); + free(p_procBuf->llrProcBuf); + + free(p_procBuf); +} +#endif diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h index 3e6c4c0c7c..f3431eba24 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h @@ -41,13 +41,15 @@ \param Z Lifting size \param BG Base graph */ -static inline void nrLDPC_llr2llrProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, uint16_t Z, uint8_t BG) +static inline void nrLDPC_llr2llrProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, t_nrLDPC_procBuf* p_procBuf, uint16_t Z, uint8_t BG) { const uint16_t* lut_llr2llrProcBuf = p_lut->llr2llrProcBuf; uint32_t i; const uint8_t numBn2CnG1 = p_lut->numBnInBnGroups[0]; uint32_t colG1 = NR_LDPC_START_COL_PARITY_BG1*Z; + int8_t* llrProcBuf = p_procBuf->llrProcBuf; + if (BG == 2) { colG1 = NR_LDPC_START_COL_PARITY_BG2*Z; @@ -74,11 +76,13 @@ static inline void nrLDPC_llr2llrProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, uint1 \param Z Lifting size \param BG Base graph */ -static inline void nrLDPC_llr2CnProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, uint16_t numLLR, uint16_t Z, uint8_t BG) +static inline void nrLDPC_llr2CnProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, t_nrLDPC_procBuf* p_procBuf, uint16_t numLLR, uint16_t Z, uint8_t BG) { const uint32_t* lut_llr2CnProcBuf = p_lut->llr2CnProcBuf; const uint8_t* lut_numEdgesPerBn = p_lut->numEdgesPerBn; + int8_t* cnProcBuf = p_procBuf->cnProcBuf; + int8_t curLLR; uint8_t numEdges; uint32_t i; @@ -123,12 +127,15 @@ static inline void nrLDPC_llr2CnProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, uint16 \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_cn2bnProcBuf(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline void nrLDPC_cn2bnProcBuf(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint32_t* lut_cn2bnProcBuf = p_lut->cn2bnProcBuf; const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; + int8_t* bnProcBuf = p_procBuf->bnProcBuf; + const uint32_t* p_lut_cn2bn; int8_t* p_cnProcBufRes; uint32_t bitOffsetInGroup; @@ -245,12 +252,15 @@ static inline void nrLDPC_cn2bnProcBuf(t_nrLDPC_lut* p_lut, uint16_t Z) \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_cn2bnProcBuf_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline void nrLDPC_cn2bnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint32_t* lut_cn2bnProcBuf = p_lut->cn2bnProcBuf; const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; + int8_t* bnProcBuf = p_procBuf->bnProcBuf; + const uint32_t* p_lut_cn2bn; int8_t* p_cnProcBufRes; uint32_t bitOffsetInGroup; @@ -418,12 +428,15 @@ static inline void nrLDPC_cn2bnProcBuf_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_bn2cnProcBuf(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline void nrLDPC_bn2cnProcBuf(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint32_t* lut_cn2bnProcBuf = p_lut->cn2bnProcBuf; const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBuf = p_procBuf->cnProcBuf; + int8_t* bnProcBufRes = p_procBuf->bnProcBufRes; + int8_t* p_cnProcBuf; const uint32_t* p_lut_cn2bn; uint32_t bitOffsetInGroup; @@ -543,12 +556,15 @@ static inline void nrLDPC_bn2cnProcBuf(t_nrLDPC_lut* p_lut, uint16_t Z) \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint32_t* lut_cn2bnProcBuf = p_lut->cn2bnProcBuf; const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBuf = p_procBuf->cnProcBuf; + int8_t* bnProcBufRes = p_procBuf->bnProcBufRes; + int8_t* p_cnProcBuf; const uint32_t* p_lut_cn2bn; uint32_t bitOffsetInGroup; @@ -720,11 +736,13 @@ static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) \param llrOut Pointer to output LLRs \param numLLR Number of LLR values */ -static inline void nrLDPC_llrRes2llrOut(t_nrLDPC_lut* p_lut, int8_t* llrOut, uint16_t numLLR) +static inline void nrLDPC_llrRes2llrOut(t_nrLDPC_lut* p_lut, int8_t* llrOut, t_nrLDPC_procBuf* p_procBuf, uint16_t numLLR) { const uint16_t* lut_llr2llrProcBuf = p_lut->llr2llrProcBuf; uint32_t i; + int8_t* llrRes = p_procBuf->llrRes; + for (i=0; illrProcBuf, NR_LDPC_MAX_NUM_LLR); break; } case nrLDPC_buffers_CN_PROC: { - nrLDPC_writeFile("cnProcBuf.txt", cnProcBuf, NR_LDPC_SIZE_CN_PROC_BUF); + nrLDPC_writeFile("cnProcBuf.txt", p_procBuf->cnProcBuf, NR_LDPC_SIZE_CN_PROC_BUF); break; } case nrLDPC_buffers_CN_PROC_RES: { - nrLDPC_writeFile("cnProcBufRes.txt", cnProcBufRes, NR_LDPC_SIZE_CN_PROC_BUF); + nrLDPC_writeFile("cnProcBufRes.txt", p_procBuf->cnProcBufRes, NR_LDPC_SIZE_CN_PROC_BUF); break; } case nrLDPC_buffers_BN_PROC: { - nrLDPC_writeFile("bnProcBuf.txt", bnProcBuf, NR_LDPC_SIZE_BN_PROC_BUF); + nrLDPC_writeFile("bnProcBuf.txt", p_procBuf->bnProcBuf, NR_LDPC_SIZE_BN_PROC_BUF); break; } case nrLDPC_buffers_BN_PROC_RES: { - nrLDPC_writeFile("bnProcBufRes.txt", bnProcBufRes, NR_LDPC_SIZE_BN_PROC_BUF); + nrLDPC_writeFile("bnProcBufRes.txt", p_procBuf->bnProcBufRes, NR_LDPC_SIZE_BN_PROC_BUF); break; } case nrLDPC_buffers_LLR_RES: { - nrLDPC_writeFile("llrRes.txt", llrRes, NR_LDPC_MAX_NUM_LLR); + nrLDPC_writeFile("llrRes.txt", p_procBuf->llrRes, NR_LDPC_MAX_NUM_LLR); break; } } diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h index 3c5128d1a1..ae32f6ffb6 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h @@ -88,4 +88,16 @@ typedef struct nrLDPC_time_stats { time_stats_t total; /**< Statistics for total processing time */ } t_nrLDPC_time_stats; +/** + Structure containing the processing buffers + */ +typedef struct nrLDPC_procBuf { + int8_t* cnProcBuf; /**< CN processing buffer */ + int8_t* cnProcBufRes; /**< Buffer for CN processing results */ + int8_t* bnProcBuf; /**< BN processing buffer */ + int8_t* bnProcBufRes; /**< Buffer for BN processing results */ + int8_t* llrRes; /**< Buffer for LLR results */ + int8_t* llrProcBuf; /**< LLR processing buffer */ +} t_nrLDPC_procBuf; + #endif diff --git a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c index be1a87e6bf..4466fc8eea 100644 --- a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c +++ b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c @@ -201,7 +201,7 @@ void encode_parity_check_part_optim(uint8_t *c,uint8_t *d, short BG,short Zc,sho int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,short block_length,short BG,time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput) { - short Zc,Kb,nrows,ncols; + short Zc,Kb=0,nrows=0,ncols=0; int i,i1; int no_punctured_columns,removed_bit; @@ -320,7 +320,7 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_input,short block_length,short BG,int n_segments,time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput) { - short Zc,Kb,nrows,ncols; + short Zc,Kb=0,nrows=0,ncols=0; int i,i1,j; int no_punctured_columns,removed_bit; //Table of possible lifting sizes @@ -520,7 +520,7 @@ int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_i int ldpc_encoder_optim_8seg_multi(unsigned char **test_input,unsigned char **channel_input,short block_length, short BG, int n_segments,unsigned int macro_num, time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput) { - short Zc,Kb,nrows,ncols; + short Zc,Kb=0,nrows=0,ncols=0; int i,i1,j; int no_punctured_columns,removed_bit; //Table of possible lifting sizes diff --git a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c index d5be3e685f..13318c9d5d 100644 --- a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c +++ b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c @@ -444,6 +444,9 @@ int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,sho no_shift_values=(short *) no_shift_values_BG2; pointer_shift_values=(short *) pointer_shift_values_BG2; } + else { + AssertFatal(0,"BG %d is not supported yet\n",BG); + } no_punctured_columns=(int)((nrows-2)*Zc+block_length-block_length*3)/Zc; removed_bit=(nrows-no_punctured_columns-2) * Zc+block_length-(block_length*3); diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index afc0f7c015..305a9c6266 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -1119,7 +1119,7 @@ uint32_t polar_decoder_int16(int16_t *input, int len=polarParams->payloadBits; - int len_mod64=len&63; + //int len_mod64=len&63; int crclen = polarParams->crcParityBits; uint64_t rxcrc=B[0]&((1<crcParityBits == 24,"support for 24-bit crc only for now\n"); - int bitlen0=bitlen; + //int bitlen0=bitlen; uint64_t tcrc=0; diff --git a/openair1/PHY/CODING/nr_rate_matching.c b/openair1/PHY/CODING/nr_rate_matching.c index 245f3b9b75..01390f1f2f 100644 --- a/openair1/PHY/CODING/nr_rate_matching.c +++ b/openair1/PHY/CODING/nr_rate_matching.c @@ -78,7 +78,7 @@ uint32_t nr_rate_matching_ldpc(uint8_t Ilbrm, { uint8_t Cprime; uint32_t Ncb,E,ind,k,Nref,N; - uint8_t *e2; + //uint8_t *e2; AssertFatal(Nl>0,"Nl is 0\n"); AssertFatal(Qm>0,"Qm is 0\n"); @@ -110,7 +110,7 @@ uint32_t nr_rate_matching_ldpc(uint8_t Ilbrm, printf("nr_rate_matching: E %d, k0 %d Cprime %d modcprime %d\n",E,ind, Cprime,((G/(Nl*Qm))%Cprime)); #endif - e2 = e; + //e2 = e; k=0; @@ -120,7 +120,8 @@ uint32_t nr_rate_matching_ldpc(uint8_t Ilbrm, printf("RM_TX k%d Ind: %d (%d)\n",k,ind,w[ind]); #endif - if (w[ind] != NR_NULL) e2[k++]=w[ind]; + //if (w[ind] != NR_NULL) e2[k++]=w[ind]; + if (w[ind] != NR_NULL) e[k++]=w[ind]; } while(kframe_parms; - nfapi_nr_config_request_t *cfg = &gNB->gNB_config; + //NR_DL_FRAME_PARMS* const fp = &gNB->frame_parms; + //nfapi_nr_config_request_t *cfg = &gNB->gNB_config; NR_gNB_COMMON* const common_vars = &gNB->common_vars; LTE_eNB_PUSCH** const pusch_vars = gNB->pusch_vars; LTE_eNB_SRS* const srs_vars = gNB->srs_vars; @@ -387,7 +387,7 @@ void install_schedule_handlers(IF_Module_t *if_inst) /// this function is a temporary addition for NR configuration -void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu) +void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,int Nid_cell) { NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; nfapi_nr_config_request_t *gNB_config = &gNB->gNB_config; @@ -403,6 +403,7 @@ void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu) gNB_config->sch_config.ssb_subcarrier_offset.value = 0; gNB_config->sch_config.n_ssb_crb.value = (N_RB_DL-20); gNB_config->sch_config.ssb_subcarrier_offset.value = 0; + gNB_config->sch_config.physical_cell_id.value=Nid_cell; gNB->mac_enabled = 1; diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 17f0d8a5d2..fc207cee84 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -656,6 +656,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int eNB_id; int th_id; int n_ssb_crb=(fp->N_RB_DL-20); + int k_ssb=0; abstraction_flag = 0; fp->nb_antennas_tx = 1; fp->nb_antennas_rx=1; @@ -664,7 +665,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, printf("Initializing UE vars (abstraction %"PRIu8") for eNB TXant %"PRIu8", UE RXant %"PRIu8"\n",abstraction_flag,fp->nb_antennas_tx,fp->nb_antennas_rx); //LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_UE][MOD %02u][]\n", ue->Mod_id+NB_eNB_INST); - nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,fp->N_RB_DL,n_ssb_crb,0); + nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,fp->N_RB_DL,n_ssb_crb,k_ssb); phy_init_nr_top(ue); // many memory allocation sizes are hard coded @@ -942,9 +943,7 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag) { void phy_init_nr_top(PHY_VARS_NR_UE *ue) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - NR_UE_DLSCH_t *dlsch0 = ue->dlsch[0][0][0]; - dlsch0 =(NR_UE_DLSCH_t *)malloc16(sizeof(NR_UE_DLSCH_t)); - + crcTableInit(); init_dfts(); diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 381a0c0452..f37883b388 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -195,10 +195,9 @@ int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp, int n_ssb_crb, int ssb_subcarrier_offset) { - + /*n_ssb_crb and ssb_subcarrier_offset are given in 15kHz SCS*/ nr_init_frame_parms0(fp,mu,Ncp,N_RB_DL); - int start_rb = n_ssb_crb / (1<ssb_start_subcarrier = 12 * start_rb + ssb_subcarrier_offset; + fp->ssb_start_subcarrier = (12 * n_ssb_crb + ssb_subcarrier_offset)/(1<harq_processes[harq_pid]->c,d_tmp,Kr,BG,dlsch->harq_processes[harq_pid]->C,NULL,NULL,NULL,NULL); + //ldpc_encoder_optim_8seg(dlsch->harq_processes[harq_pid]->c,d_tmp,Kr,BG,dlsch->harq_processes[harq_pid]->C,NULL,NULL,NULL,NULL); + ldpc_encoder_optim_8seg(dlsch->harq_processes[harq_pid]->c,dlsch->harq_processes[harq_pid]->d,Kr,BG,dlsch->harq_processes[harq_pid]->C,NULL,NULL,NULL,NULL); //stop_meas(te_stats); //printf("end ldpc encoder -- output\n"); diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index a978c31d99..2e2c99f106 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -53,7 +53,7 @@ int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, NR_DL_FRAME_PARMS *frame_parms) { int k,l; - int16_t a; + //int16_t a; int16_t mod_dmrs[NR_PBCH_DMRS_LENGTH<<1]; uint8_t idx=0; uint8_t nushift = config->sch_config.physical_cell_id.value &3; @@ -240,7 +240,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, { int k,l,m; - int16_t a; + //int16_t a; int16_t mod_pbch_e[NR_POLAR_PBCH_E]; uint8_t idx=0; uint16_t M; diff --git a/openair1/PHY/NR_TRANSPORT/nr_sss.c b/openair1/PHY/NR_TRANSPORT/nr_sss.c index 1143b96aec..154aca9ffe 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_sss.c +++ b/openair1/PHY/NR_TRANSPORT/nr_sss.c @@ -33,7 +33,7 @@ int nr_generate_sss( int16_t *d_sss, int i,k,l; int m0, m1; int Nid, Nid1, Nid2; - int16_t a; + //int16_t a; int16_t x0[NR_SSS_LENGTH], x1[NR_SSS_LENGTH]; const int x0_initial[7] = { 1, 0, 0, 0, 0, 0, 0 }; const int x1_initial[7] = { 1, 0, 0, 0, 0, 0, 0 }; diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h index 3c318874ac..b075da4e97 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h @@ -1,3 +1,4 @@ + /* * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more * contributor license agreements. See the NOTICE file distributed with @@ -33,7 +34,7 @@ #ifndef __NR_TRANSPORT_COMMON_PROTO__H__ #define __NR_TRANSPORT_COMMON_PROTO__H__ -#define MAX_NUM_NR_DLSCH_SEGMENTS 32 +#define MAX_NUM_NR_DLSCH_SEGMENTS 16 #define MAX_NUM_NR_ULSCH_SEGMENTS MAX_NUM_NR_DLSCH_SEGMENTS #define MAX_NR_DLSCH_PAYLOAD_BYTES (MAX_NUM_NR_DLSCH_SEGMENTS*1056) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index f072532d27..cf419b0904 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -1131,7 +1131,7 @@ void nr_dci_decoding_procedure0(int s, //Table 10.1-2: Maximum number of PDCCH candidates per slot and per serving cell as a function of the subcarrier spacing value 2^mu*15 KHz, mu {0,1,2,3} uint8_t m_max_slot_pdcch_Table10_1_2 [4] = {44,36,22,20}; //Table 10.1-3: Maximum number of non-overlapped CCEs per slot and per serving cell as a function of the subcarrier spacing value 2^mu*15 KHz, mu {0,1,2,3} - uint8_t cce_max_slot_pdcch_Table10_1_3 [4] = {56,56,48,32}; + //uint8_t cce_max_slot_pdcch_Table10_1_3 [4] = {56,56,48,32}; int coreset_nbr_cce_per_symbol=0; @@ -1264,9 +1264,10 @@ void nr_dci_decoding_procedure0(int s, for (m = 0; m < nb_candidates; m++) { int n_ci = 0; if (nCCE[p] < L2) return; + +#ifdef NR_PDCCH_DCI_DEBUG int debug1 = nCCE[p] / L2; int debug2 = L2*m_p_s_L_max; -#ifdef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> debug1(%d)=nCCE[p]/L2 | nCCE[%d](%d) | L2(%d)\n",debug1,p,nCCE[p],L2); printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> debug2(%d)=L2*m_p_s_L_max | L2(%d) | m_p_s_L_max(%d)\n",debug2,L2,m_p_s_L_max); #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 428dfc9e99..610b8305df 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -35,6 +35,7 @@ #include "PHY/CODING/coding_extern.h" #include "PHY/CODING/coding_defs.h" #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" +#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "SCHED_NR_UE/defs.h" #include "SIMULATION/TOOLS/sim.h" @@ -45,8 +46,6 @@ #define OAI_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX -static int8_t llrProcBuf[OAI_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); - static uint64_t nb_total_decod =0; static uint64_t nb_error_decod =0; @@ -75,12 +74,19 @@ void free_nr_ue_dlsch(NR_UE_DLSCH_t *dlsch) free16(dlsch->harq_processes[i]->d[r],(3*8448)*sizeof(short)); dlsch->harq_processes[i]->d[r] = NULL; } + + for (r=0; r<(MAX_NUM_NR_DLSCH_SEGMENTS); r++) { + if (dlsch->harq_processes[i]->p_nrLDPC_procBuf[r]){ + nrLDPC_free_mem(dlsch->harq_processes[i]->p_nrLDPC_procBuf[r]); + dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL; + } + } free16(dlsch->harq_processes[i],sizeof(NR_DL_UE_HARQ_t)); dlsch->harq_processes[i] = NULL; } } - + free16(dlsch,sizeof(NR_UE_DLSCH_t)); dlsch = NULL; } @@ -120,7 +126,7 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint dlsch->Mdlharq = Mdlharq; dlsch->Nsoft = Nsoft; dlsch->max_ldpc_iterations = max_ldpc_iterations; - + for (i=0; iharq_processes[i] = (NR_DL_UE_HARQ_t *)malloc16(sizeof(NR_DL_UE_HARQ_t)); @@ -136,7 +142,8 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint exit_flag=3; if (abstraction_flag == 0) { - for (r=0; rharq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem(); dlsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(1056); if (dlsch->harq_processes[i]->c[r]) @@ -190,7 +197,7 @@ void nr_dlsch_unscrambling(int16_t* llr, } -uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, +uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, short *dlsch_llr, NR_DL_FRAME_PARMS *frame_parms, NR_UE_DLSCH_t *dlsch, @@ -215,10 +222,13 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, //short dummy_w[MAX_NUM_DLSCH_SEGMENTS][3*(8448+64)]; uint32_t r,r_offset=0,Kr=8424,Kr_bytes,K_bytes_F,err_flag=0; uint8_t crc_type; + int8_t llrProcBuf[OAI_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); t_nrLDPC_dec_params decParams; t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; + t_nrLDPC_procBuf** p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf; + int16_t z [68*384]; int8_t l [68*384]; //__m128i l; @@ -506,7 +516,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, no_iteration_ldpc = nrLDPC_decoder(p_decParams, (int8_t*)&pl[0], llrProcBuf, - p_procTime); + p_nrLDPC_procBuf[r], + p_procTime); if (check_crc(llrProcBuf,harq_process->B,harq_process->F,crc_type)) { printf("CRC OK\n"); @@ -691,6 +702,9 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; + int8_t llrProcBuf[OAI_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); + t_nrLDPC_procBuf* p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf[0]; + int16_t z [68*384]; int8_t l [68*384]; //__m128i l; @@ -786,7 +800,7 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, kb = harq_process->K/harq_process->Z; if ( kb==22){ p_decParams->BG = 1; - p_decParams->R = 89; + p_decParams->R = 13; kc = 68; } else{ @@ -825,7 +839,7 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, return((1+dlsch->max_ldpc_iterations)); } #ifdef DEBUG_DLSCH_DECODING - printf("Segmentation: C %d, Cminus %d, Kminus %d, Kplus %d\n",harq_process->C,harq_process->Cminus,harq_process->Kminus,harq_process->Kplus); + printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K); #endif opp_enabled=1; @@ -955,7 +969,9 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment Cby2 = 1; } - for (r=0; rK; Kr_bytes = Kr>>3; @@ -1007,8 +1023,13 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment stop_meas(dlsch_rate_unmatching_stats); #endif } - r_offset += E; + //r_offset += E; //printf("main thread r_offset %d\n",r_offset); + +#ifdef DEBUG_DLSCH_DECODING + for (int i =0; i<16; i++) + printf("rx output ratematching w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset); +#endif /* printf("Subblock deinterleaving, d %p w %p\n", @@ -1022,6 +1043,11 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment harq_process->Qm, harq_process->d[r], harq_process->w[r]); +#ifdef DEBUG_DLSCH_DECODING + for (int i =0; i<16; i++) + printf("rx output interleaving d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset); +#endif + #if UE_TIMING_TRACE stop_meas(dlsch_deinterleaving_stats); #endif @@ -1064,6 +1090,10 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment start_meas(dlsch_turbo_decoding_stats); #endif LOG_D(PHY,"mthread AbsSubframe %d.%d Start turbo segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1); + + for (int cnt =0; cnt < (kc-2)*p_decParams->Z; cnt++){ + inv_d[cnt] = (1)*harq_process->d[r][cnt]; + } memset(pv,0,2*p_decParams->Z*sizeof(int16_t)); //memset(pl,0,2*p_decParams->Z*sizeof(int8_t)); @@ -1090,6 +1120,7 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment no_iteration_ldpc = nrLDPC_decoder(p_decParams, (int8_t*)&pl[0], llrProcBuf, + p_nrLDPC_procBuf, p_procTime); nb_total_decod++; @@ -1100,6 +1131,16 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment else { ret=2; } + + if (check_crc(llrProcBuf,harq_process->B,harq_process->F,crc_type)) { + printf("CRC OK\n"); + ret = 2; + } + else { + printf("CRC NOK\n"); + ret = 1+dlsch->max_ldpc_iterations; + } + //if (!nb_total_decod%10000){ printf("Error number of iteration LPDC %d %ld/%ld \n", no_iteration_ldpc, nb_error_decod,nb_total_decod);fflush(stdout); //} @@ -1130,7 +1171,10 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment //printf("output channel decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); //printf("output decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); - +#ifdef DEBUG_DLSCH_DECODING + for (int k=0;k<32;k++) + printf("output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); +#endif #if UE_TIMING_TRACE stop_meas(dlsch_turbo_decoding_stats); @@ -1142,7 +1186,7 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment LOG_D(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1); err_flag = 1; } - } + //} //loop r int32_t frame_rx_prev = frame; int32_t tti_rx_prev = nr_tti_rx - 1; @@ -1273,6 +1317,8 @@ void *nr_dlsch_decoding_2thread0(void *arg) t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; + int8_t llrProcBuf[OAI_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); + t_nrLDPC_procBuf* p_nrLDPC_procBuf; int16_t z [68*384]; int8_t l [68*384]; //__m128i l; @@ -1365,6 +1411,7 @@ void *nr_dlsch_decoding_2thread0(void *arg) NR_DL_UE_HARQ_t *harq_process = dlsch->harq_processes[harq_pid]; short *dlsch_llr = phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr[0]; //printf("2thread0 llr flag %d tdp flag %d\n",llr8_flag1, tdp->llr8_flag); + p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf[1]; /* if (nb_rb > frame_parms->N_RB_DL) { @@ -1410,7 +1457,7 @@ void *nr_dlsch_decoding_2thread0(void *arg) kb = harq_process->K/harq_process->Z; if ( kb==22){ p_decParams->BG = 1; - p_decParams->R = 89; + p_decParams->R = 13; kc = 68; } else{ @@ -1523,7 +1570,7 @@ void *nr_dlsch_decoding_2thread0(void *arg) stop_meas(dlsch_rate_unmatching_stats); #endif } - r_offset += E; + //r_offset += E; //for (int i =0; i<16; i++) // printf("rx output ratematching w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset); @@ -1606,6 +1653,7 @@ void *nr_dlsch_decoding_2thread0(void *arg) no_iteration_ldpc = nrLDPC_decoder(p_decParams, (int8_t*)&pl[0], llrProcBuf, + p_nrLDPC_procBuf, p_procTime); if (no_iteration_ldpc > 10) @@ -1633,6 +1681,10 @@ void *nr_dlsch_decoding_2thread0(void *arg) } printf(" \n");*/ +#ifdef DEBUG_DLSCH_DECODING + for (int k=0;k<2;k++) + printf("segment 1 output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); +#endif #if UE_TIMING_TRACE stop_meas(dlsch_turbo_decoding_stats); @@ -1778,6 +1830,8 @@ void *nr_dlsch_decoding_2thread1(void *arg) t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; + t_nrLDPC_procBuf* p_nrLDPC_procBuf; + int8_t llrProcBuf[OAI_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); int16_t z [68*384]; int8_t l [68*384]; //__m128i l; @@ -1871,6 +1925,7 @@ void *nr_dlsch_decoding_2thread1(void *arg) short *dlsch_llr = phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr[0]; //printf("2thread0 llr flag %d tdp flag %d\n",llr8_flag1, tdp->llr8_flag); //printf("2thread1 nr_tti_tx %d subframe %d SF thread id %d r_offset %d\n", proc->nr_tti_rx, subframe, phy_vars_ue->current_thread_id[subframe], r_offset); + p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf[2]; /* if (nb_rb > frame_parms->N_RB_DL) { @@ -2032,7 +2087,7 @@ void *nr_dlsch_decoding_2thread1(void *arg) stop_meas(dlsch_rate_unmatching_stats); #endif } - r_offset += E; + //r_offset += E; /* printf("Subblock deinterleaving, d %p w %p\n", @@ -2110,6 +2165,7 @@ void *nr_dlsch_decoding_2thread1(void *arg) no_iteration_ldpc = nrLDPC_decoder(p_decParams, (int8_t*)&pl[0], llrProcBuf, + p_nrLDPC_procBuf, p_procTime); if (no_iteration_ldpc > 10) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 2e00c128b3..a9f6b02567 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -131,10 +131,10 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, unsigned short nb_rb_pdsch = 50; int16_t *pllr_symbol_cw0; int16_t *pllr_symbol_cw1; - int16_t *pllr_symbol_cw0_deint; - int16_t *pllr_symbol_cw1_deint; + //int16_t *pllr_symbol_cw0_deint; + //int16_t *pllr_symbol_cw1_deint; uint32_t llr_offset_symbol; - uint16_t bundle_L = 2; + //uint16_t bundle_L = 2; uint8_t l0 =2; switch (type) { @@ -2001,7 +2001,7 @@ unsigned short nr_dlsch_extract_rbs_single(int **rxdataF, unsigned short k,rb; - unsigned char i,aarx,l; //,nsymb,sss_symb,pss_symb=0; + unsigned char i,aarx; //,nsymb,sss_symb,pss_symb=0,l; int *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext; @@ -2010,7 +2010,7 @@ unsigned short nr_dlsch_extract_rbs_single(int **rxdataF, //symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; pilots = (symbol==2) ? 1 : 0; //to updated from config - l=symbol; + //l=symbol; //nsymb = (frame_parms->Ncp==NORMAL) ? 14:12; k = frame_parms->first_carrier_offset + 516; //0 diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 50a283f465..4a6e6423f6 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -140,7 +140,7 @@ char prefix_string[2][9] = {"NORMAL","EXTENDED"}; int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) { - int32_t sync_pos, sync_pos2, sync_pos_slot; // k_ssb, N_ssb_crb, + int32_t sync_pos, sync_pos_slot; // k_ssb, N_ssb_crb, sync_pos2, int32_t metric_tdd_ncp=0; uint8_t phase_tdd_ncp; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 3e5df2e242..a0b150eda1 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -51,8 +51,8 @@ uint16_t nr_pbch_extract(int **rxdataF, int **rxdataF_ext, int **dl_ch_estimates_ext, uint32_t symbol, + uint32_t s_offset, uint32_t high_speed_flag, - int is_synchronized, NR_DL_FRAME_PARMS *frame_parms) { @@ -65,18 +65,15 @@ uint16_t nr_pbch_extract(int **rxdataF, unsigned int rx_offset = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier; //and if (rx_offset>= frame_parms->ofdm_symbol_size) rx_offset-=frame_parms->ofdm_symbol_size; - int s_offset=0; AssertFatal(symbol>=1 && symbol<5, "symbol %d illegal for PBCH extraction\n", symbol); - if (is_synchronized==1) s_offset=4; - for (aarx=0; aarxnb_antennas_rx; aarx++) { rxF = &rxdataF[aarx][(symbol+s_offset)*frame_parms->ofdm_symbol_size]; - rxF_ext = &rxdataF_ext[aarx][(symbol+s_offset)*(20*12)]; + rxF_ext = &rxdataF_ext[aarx][symbol*20*12]; #ifdef DEBUG_PBCH printf("extract_rbs (nushift %d): rx_offset=%d, symbol %d\n",frame_parms->nushift, (rx_offset + ((symbol+s_offset)*(frame_parms->ofdm_symbol_size))),symbol); @@ -143,7 +140,7 @@ uint16_t nr_pbch_extract(int **rxdataF, //printf("dl_ch0 addr %p\n",dl_ch0); - dl_ch0_ext = &dl_ch_estimates_ext[aarx][(symbol+s_offset)*(20*12)]; + dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*20*12]; for (rb=0; rb<20; rb++) { j=0; @@ -268,8 +265,7 @@ void nr_pbch_channel_compensation(int **rxdataF_ext, int **dl_ch_estimates_ext, int **rxdataF_comp, NR_DL_FRAME_PARMS *frame_parms, - uint8_t symbol, - int is_synchronized, + uint32_t symbol, uint8_t output_shift) { @@ -290,14 +286,11 @@ void nr_pbch_channel_compensation(int **rxdataF_ext, #endif - AssertFatal((symbol > 0 && symbol < 4 && is_synchronized == 0) || - (symbol > 4 && symbol < 8 && is_synchronized == 1), - "symbol %d is illegal for PBCH DM-RS (is_synchronized %d)\n", - symbol,is_synchronized); + AssertFatal((symbol > 0 && symbol < 4), + "symbol %d is illegal for PBCH DM-RS\n", + symbol); - - - if (symbol == 2 || symbol == 6) nb_re = 72; + if (symbol == 2) nb_re = 72; // printf("comp: symbol %d : nb_re %d\n",symbol,nb_re); @@ -559,31 +552,35 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, // clear LLR buffer memset(nr_ue_pbch_vars->llr,0,NR_POLAR_PBCH_E); - int first_symbol=1; - if (ue->is_synchronized > 0) first_symbol+=4; + int symbol_offset=1; + if (ue->is_synchronized > 0) + symbol_offset=4; + else + symbol_offset=0; #ifdef DEBUG_PBCH //printf("address dataf %p",nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF); write_output("rxdataF0_pbch.m","rxF0pbch", - &nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF[0][first_symbol*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size*3,1,1); + &nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF[0][(symbol_offset+1)*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size*3,1,1); #endif - for (symbol=first_symbol; symbol<(first_symbol+3); symbol++) { + // symbol refers to symbol within SSB. symbol_offset is the offset of the SSB wrt start of slot + for (symbol=1; symbol<4; symbol++) { nr_pbch_extract(nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF, nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].dl_ch_estimates[eNB_id], nr_ue_pbch_vars->rxdataF_ext, nr_ue_pbch_vars->dl_ch_estimates_ext, - symbol-first_symbol+1, + symbol, + symbol_offset, high_speed_flag, - ue->is_synchronized, frame_parms); #ifdef DEBUG_PBCH LOG_I(PHY,"[PHY] PBCH Symbol %d ofdm size %d\n",symbol, frame_parms->ofdm_symbol_size ); LOG_I(PHY,"[PHY] PBCH starting channel_level\n"); #endif - if (symbol == 1 || symbol == 5) { + if (symbol == 1) { max_h = nr_pbch_channel_level(nr_ue_pbch_vars->dl_ch_estimates_ext, frame_parms, symbol); @@ -599,7 +596,6 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, nr_ue_pbch_vars->rxdataF_comp, frame_parms, symbol, - ue->is_synchronized, nr_ue_pbch_vars->log2_maxh); // log2_maxh+I0_shift /*if (frame_parms->nb_antennas_rx > 1) @@ -615,7 +611,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, return(-1); } */ - if (symbol==(first_symbol+1)) { + if (symbol==1) { nr_pbch_quantize(pbch_e_rx, (short*)&(nr_ue_pbch_vars->rxdataF_comp[0][symbol*240]), 144); @@ -633,7 +629,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, } #ifdef DEBUG_PBCH - write_output("rxdataF_comp.m","rxFcomp",&nr_ue_pbch_vars->rxdataF_comp[0][240*first_symbol],240*3,1,1); + write_output("rxdataF_comp.m","rxFcomp",&nr_ue_pbch_vars->rxdataF_comp[0][240],240*3,1,1); #endif @@ -644,7 +640,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, #ifdef DEBUG_PBCH //pbch_e_rx = &nr_ue_pbch_vars->llr[0]; - short *p = (short *)&(nr_ue_pbch_vars->rxdataF_comp[0][first_symbol*20*12]); + short *p = (short *)&(nr_ue_pbch_vars->rxdataF_comp[0][20*12]); for (int cnt = 0; cnt < 864 ; cnt++) printf("pbch rx llr %d\n",*(pbch_e_rx+cnt)); @@ -720,14 +716,13 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ue->dl_indication.rx_ind = &ue->rx_ind; // hang on rx_ind instance //ue->rx_ind.sfn_slot = 0; //should be set by higher-1-layer, i.e. clean_and_set_if_instance() - ue->rx_ind.number_pdus = ue->rx_ind.number_pdus + 1; - ue->rx_ind.rx_indication_body = (fapi_nr_rx_indication_body_t *)malloc(sizeof(fapi_nr_rx_indication_body_t)); - ue->rx_ind.rx_indication_body->pdu_type = FAPI_NR_RX_PDU_TYPE_MIB; - ue->rx_ind.rx_indication_body->mib_pdu.pdu = &decoded_output[0]; - ue->rx_ind.rx_indication_body->mib_pdu.additional_bits = xtra_byte; - ue->rx_ind.rx_indication_body->mib_pdu.ssb_index = ssb_index; // confirm with TCL - ue->rx_ind.rx_indication_body->mib_pdu.ssb_length = Lmax; // confirm with TCL - ue->rx_ind.rx_indication_body->mib_pdu.cell_id = frame_parms->Nid_cell; // confirm with TCL + ue->rx_ind.rx_indication_body[0].pdu_type = FAPI_NR_RX_PDU_TYPE_MIB; + ue->rx_ind.rx_indication_body[0].mib_pdu.pdu = &decoded_output[0]; + ue->rx_ind.rx_indication_body[0].mib_pdu.additional_bits = xtra_byte; + ue->rx_ind.rx_indication_body[0].mib_pdu.ssb_index = ssb_index; // confirm with TCL + ue->rx_ind.rx_indication_body[0].mib_pdu.ssb_length = Lmax; // confirm with TCL + ue->rx_ind.rx_indication_body[0].mib_pdu.cell_id = frame_parms->Nid_cell; // confirm with TCL + ue->rx_ind.number_pdus = 1; if (ue->if_inst && ue->if_inst->dl_indication) ue->if_inst->dl_indication(&ue->dl_indication); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c index 0a662304dd..9c7146ca03 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c @@ -40,6 +40,7 @@ //#include "PHY/defs_nr_common.h" #include "PHY/defs_nr_UE.h" #include "PHY/NR_UE_TRANSPORT/nr_prach.h" +#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" //#include "PHY/extern.h" //#include "LAYER2/MAC/extern.h" //#include "PHY/NR_UE_TRANSPORT/pucch_nr.h" @@ -574,7 +575,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, uint8_t restricted_set = ue->frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag; //uint8_t n_ra_prboffset = ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset; uint8_t preamble_index = ue->prach_resources[eNB_id]->ra_PreambleIndex; - uint8_t tdd_mapindex = ue->prach_resources[eNB_id]->ra_TDD_map_index; + //uint8_t tdd_mapindex = ue->prach_resources[eNB_id]->ra_TDD_map_index; int16_t *prachF = ue->prach_vars[eNB_id]->prachF; static int16_t prach_tmp[45600*2] __attribute__((aligned(32))); int16_t *prach = prach_tmp; @@ -582,7 +583,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, int16_t amp = ue->prach_vars[eNB_id]->amp; int16_t Ncp; uint8_t n_ra_prb; - uint16_t NCS; + uint16_t NCS=0; uint16_t *prach_root_sequence_map; uint16_t preamble_offset,preamble_shift; uint16_t preamble_index0,n_shift_ra,n_shift_ra_bar; @@ -599,7 +600,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, int32_t Xu_re,Xu_im; uint16_t offset,offset2; int prach_start; - int i, prach_len; + int i, prach_len=0; uint16_t first_nonzero_root_idx=0; #if defined(EXMIMO) || defined(OAI_USRP) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index f89816c782..b41b23dd32 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -34,7 +34,7 @@ #include #include "PHY/impl_defs_top.h" - +#include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h" //#include "PHY/defs_nr_UE.h" #include "../NR_TRANSPORT/nr_transport_common_proto.h" @@ -267,6 +267,8 @@ typedef struct { double w_abs[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) int16_t *d[MAX_NUM_NR_DLSCH_SEGMENTS]; + /// LDPC processing buffers + t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_DLSCH_SEGMENTS]; /// Number of code segments uint32_t C; /// Number of bits in code segments @@ -353,9 +355,7 @@ typedef struct { /// Maximum number of LDPC iterations uint8_t max_ldpc_iterations; /// number of iterations used in last turbo decoding - uint8_t last_iteration_cnt; - - + uint8_t last_iteration_cnt; } NR_UE_DLSCH_t; typedef enum {format0_0, diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index 5ac83b5280..01481d3612 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -862,8 +862,8 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain //((short*)pss_corr_ue[pss_index])[2*n] += ((short*) &result)[0]; /* real part */ //((short*)pss_corr_ue[pss_index])[2*n+1] += ((short*) &result)[1]; /* imaginary part */ - //((short*)&synchro_out)[0] += ((short*) &result)[0]; /* real part */ - //((short*)&synchro_out)[1] += ((short*) &result)[1]; /* imaginary part */ + //((short*)&synchro_out)[0] += ((int*) &result)[0]; /* real part */ + //((short*)&synchro_out)[1] += ((int*) &result)[1]; /* imaginary part */ } } diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c index e2accc340b..05ab023b00 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c @@ -36,6 +36,7 @@ //#include "PHY/extern.h" //#include "LAYER2/MAC/extern.h" #include "PHY/NR_UE_TRANSPORT/pucch_nr.h" +#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" @@ -129,7 +130,7 @@ double nr_cyclic_shift_hopping(PHY_VARS_NR_UE *ue, */ // alpha_init initialized to 2*PI/12=0.5235987756 double alpha = 0.5235987756; - uint16_t c_init = ue->pucch_config_common_nr->hoppingId; // we initialize c_init again to calculate n_cs + uint32_t c_init = ue->pucch_config_common_nr->hoppingId; // we initialize c_init again to calculate n_cs #ifdef DEBUG_NR_PUCCH_TX // initialization to be removed @@ -181,9 +182,9 @@ void nr_generate_pucch0(PHY_VARS_NR_UE *ue, // alpha is cyclic shift double alpha; // lnormal is the OFDM symbol number in the PUCCH transmission where l=0 corresponds to the first OFDM symbol of the PUCCH transmission - uint8_t lnormal; + //uint8_t lnormal; // lprime is the index of the OFDM symbol in the slot that corresponds to the first OFDM symbol of the PUCCH transmission in the slot given by [5, TS 38.213] - uint8_t lprime; + //uint8_t lprime; // mcs is provided by TC 38.213 subclauses 9.2.3, 9.2.4, 9.2.5 FIXME! //uint8_t mcs; @@ -198,7 +199,7 @@ void nr_generate_pucch0(PHY_VARS_NR_UE *ue, * x(l*12+n) = r_u_v_alpha_delta(n) */ // the value of u,v (delta always 0 for PUCCH) has to be calculated according to TS 38.211 Subclause 6.3.2.2.1 - uint8_t u=0,v=0,delta=0; + uint8_t u=0,v=0;//,delta=0; // if frequency hopping is disabled by the higher-layer parameter PUCCH-frequency-hopping // n_hop = 0 // if frequency hopping is enabled by the higher-layer parameter PUCCH-frequency-hopping @@ -236,8 +237,8 @@ void nr_generate_pucch0(PHY_VARS_NR_UE *ue, /* * Implementing TS 38.211 Subclause 6.3.2.3.2 Mapping to physical resources FIXME! */ - int32_t *txptr; - uint32_t re_offset; + //int32_t *txptr; + uint32_t re_offset=0; for (int l=0; lN_RB_DL>>1)) && ((frame_parms->N_RB_DL & 1) == 0)) { // if number RBs in bandwidth is even and current PRB is lower band re_offset = ((l+startingSymbolIndex)*frame_parms->ofdm_symbol_size) + (12*startingPRB) + frame_parms->first_carrier_offset; @@ -254,7 +255,7 @@ void nr_generate_pucch0(PHY_VARS_NR_UE *ue, if ((startingPRB == (frame_parms->N_RB_DL>>1)) && ((frame_parms->N_RB_DL & 1) == 1)) { // if number RBs in bandwidth is odd and current PRB contains DC re_offset = ((l+startingSymbolIndex)*frame_parms->ofdm_symbol_size) + (12*startingPRB) + frame_parms->first_carrier_offset; } - txptr = &txdataF[0][re_offset]; + //txptr = &txdataF[0][re_offset]; for (int n=0; n<12; n++){ if ((n==6) && (startingPRB == (frame_parms->N_RB_DL>>1)) && ((frame_parms->N_RB_DL & 1) == 1)) { // if number RBs in bandwidth is odd and current PRB contains DC, we need to recalculate the offset when n=6 (for second half PRB) @@ -299,7 +300,7 @@ void nr_generate_pucch1(PHY_VARS_NR_UE *ue, * */ // complex-valued symbol d_re, d_im containing complex-valued symbol d(0): - int16_t d_re, d_im; + int16_t d_re=0, d_im=0; if (nr_bit == 1) { // using BPSK if M_bit=1 according to TC 38.211 Subclause 5.1.2 d_re = (payload&1)==0 ? (int16_t)(((int32_t)amp*ONE_OVER_SQRT2)>>15) : -(int16_t)(((int32_t)amp*ONE_OVER_SQRT2)>>15); d_im = (payload&1)==0 ? (int16_t)(((int32_t)amp*ONE_OVER_SQRT2)>>15) : -(int16_t)(((int32_t)amp*ONE_OVER_SQRT2)>>15); @@ -332,7 +333,7 @@ void nr_generate_pucch1(PHY_VARS_NR_UE *ue, // alpha is cyclic shift double alpha; // lnormal is the OFDM symbol number in the PUCCH transmission where l=0 corresponds to the first OFDM symbol of the PUCCH transmission - uint8_t lnormal = 0 ; + //uint8_t lnormal = 0 ; // lprime is the index of the OFDM symbol in the slot that corresponds to the first OFDM symbol of the PUCCH transmission in the slot given by [5, TS 38.213] uint8_t lprime = startingSymbolIndex; // mcs = 0 except for PUCCH format 0 @@ -350,7 +351,7 @@ void nr_generate_pucch1(PHY_VARS_NR_UE *ue, * the complex-valued symbol d_0 shall be multiplied with a sequence r_u_v_alpha_delta(n): y(n) = d_0 * r_u_v_alpha_delta(n) */ // the value of u,v (delta always 0 for PUCCH) has to be calculated according to TS 38.211 Subclause 6.3.2.2.1 - uint8_t u=0,v=0,delta=0; + uint8_t u=0,v=0;//,delta=0; // if frequency hopping is disabled, intraSlotFrequencyHopping is not provided // n_hop = 0 // if frequency hopping is enabled, intraSlotFrequencyHopping is provided @@ -371,8 +372,8 @@ void nr_generate_pucch1(PHY_VARS_NR_UE *ue, /* * Implementing TS 38.211 Subclause 6.3.2.4.2 Mapping to physical resources */ - int32_t *txptr; - uint32_t re_offset; + //int32_t *txptr; + uint32_t re_offset=0; int i=0; #define MAX_SIZE_Z 168 // this value has to be calculated from mprime*12*table_6_3_2_4_1_1_N_SF_mprime_PUCCH_1_noHop[pucch_symbol_length]+m*12+n int16_t z_re[MAX_SIZE_Z],z_im[MAX_SIZE_Z]; @@ -552,7 +553,7 @@ void nr_generate_pucch1(PHY_VARS_NR_UE *ue, } - txptr = &txdataF[0][re_offset]; + //txptr = &txdataF[0][re_offset]; for (int n=0; n<12; n++){ if ((n==6) && (startingPRB == (frame_parms->N_RB_DL>>1)) && ((frame_parms->N_RB_DL & 1) == 1)) { // if number RBs in bandwidth is odd and current PRB contains DC, we need to recalculate the offset when n=6 (for second half PRB) @@ -904,7 +905,7 @@ void nr_uci_encoding(uint64_t payload, // L is the CRC size uint8_t L; // E is the rate matching output sequence length as given in TS 38.212 subclause 6.3.1.4.1 - uint16_t E,E_init; + uint16_t E=0,E_init; if (fmt == pucch_format2_nr) E = 16*nrofSymbols*nrofPRB; if (fmt == pucch_format3_nr){ E_init = (is_pi_over_2_bpsk_enabled == 0) ? 24:12; @@ -1061,8 +1062,8 @@ void nr_generate_pucch2(PHY_VARS_NR_UE *ue, /* * Implementing TS 38.211 Subclause 6.3.2.5.3 Mapping to physical resources */ - int32_t *txptr; - uint32_t re_offset; + //int32_t *txptr; + uint32_t re_offset=0; uint32_t x1, x2, s=0; int i=0; int m=0; @@ -1086,7 +1087,7 @@ void nr_generate_pucch2(PHY_VARS_NR_UE *ue, if (((rb+startingPRB) == (frame_parms->N_RB_DL>>1)) && ((frame_parms->N_RB_DL & 1) == 1)) { // if number RBs in bandwidth is odd and current PRB contains DC re_offset = ((l+startingSymbolIndex)*frame_parms->ofdm_symbol_size) + (12*(rb+startingPRB)) + frame_parms->first_carrier_offset; } - txptr = &txdataF[0][re_offset]; + //txptr = &txdataF[0][re_offset]; int k=0; int kk=0; for (int n=0; n<12; n++){ @@ -1286,7 +1287,7 @@ void nr_generate_pucch3_4(PHY_VARS_NR_UE *ue, {0, 0, 0,-1,-1,-1, 0, 0, 0, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0,-1,-1,-1}}; - uint8_t occ_Length = occ_length_format4; // higher layer parameter occ-Length + //uint8_t occ_Length = occ_length_format4; // higher layer parameter occ-Length uint8_t occ_Index = occ_index_format4; // higher layer parameter occ-Index //occ_Index = 1; //only for testing purposes; to be removed FIXME!!! if (fmt == pucch_format3_nr){ // no block-wise spreading for format 3 @@ -1377,7 +1378,7 @@ void nr_generate_pucch3_4(PHY_VARS_NR_UE *ue, * Implementing TS 38.211 Subclauses 6.3.2.5.3 and 6.3.2.6.5 Mapping to physical resources */ // the value of u,v (delta always 0 for PUCCH) has to be calculated according to TS 38.211 Subclause 6.3.2.2.1 - uint8_t u=0,v=0,delta=0; + uint8_t u=0,v=0;//,delta=0; // if frequency hopping is disabled, intraSlotFrequencyHopping is not provided // n_hop = 0 // if frequency hopping is enabled, intraSlotFrequencyHopping is provided @@ -1385,9 +1386,9 @@ void nr_generate_pucch3_4(PHY_VARS_NR_UE *ue, // n_hop = 1 for second hop uint8_t n_hop = 0; // lnormal is the OFDM symbol number in the PUCCH transmission where l=0 corresponds to the first OFDM symbol of the PUCCH transmission - uint8_t lnormal = 0 ; + //uint8_t lnormal = 0 ; // lprime is the index of the OFDM symbol in the slot that corresponds to the first OFDM symbol of the PUCCH transmission in the slot given by [5, TS 38.213] - uint8_t lprime = startingSymbolIndex; + //uint8_t lprime = startingSymbolIndex; // m0 is the cyclic shift index calculated depending on the Orthogonal sequence index n, according to table 6.4.1.3.3.1-1 from TS 38.211 subclause 6.4.1.3.3.1 uint8_t m0; uint8_t mcs=0; @@ -1404,13 +1405,13 @@ void nr_generate_pucch3_4(PHY_VARS_NR_UE *ue, uint8_t N_ZC = 12*nrofPRB; int16_t *r_u_v_base_re = malloc(sizeof(int16_t)*12*nrofPRB); int16_t *r_u_v_base_im = malloc(sizeof(int16_t)*12*nrofPRB); - int16_t *r_u_v_alpha_delta_re = malloc(sizeof(int16_t)*12*nrofPRB); - int16_t *r_u_v_alpha_delta_im = malloc(sizeof(int16_t)*12*nrofPRB); + //int16_t *r_u_v_alpha_delta_re = malloc(sizeof(int16_t)*12*nrofPRB); + //int16_t *r_u_v_alpha_delta_im = malloc(sizeof(int16_t)*12*nrofPRB); // Next we proceed to mapping to physical resources according to TS 38.211, subclause 6.3.2.6.5 dor PUCCH formats 3 and 4 and subclause 6.4.1.3.3.2 for DM-RS - int32_t *txptr; - uint32_t re_offset; - uint32_t x1, x2, s=0; + //int32_t *txptr; + uint32_t re_offset=0; + //uint32_t x1, x2, s=0; // intraSlotFrequencyHopping // uint8_t intraSlotFrequencyHopping = 0; uint8_t table_6_4_1_3_3_2_1_dmrs_positions[11][14] ={ @@ -1513,7 +1514,7 @@ void nr_generate_pucch3_4(PHY_VARS_NR_UE *ue, #ifdef DEBUG_NR_PUCCH_TX printf("re_offset=%d,(rb+startingPRB)=%d\n",re_offset,(rb+startingPRB)); #endif - txptr = &txdataF[0][re_offset]; + //txptr = &txdataF[0][re_offset]; for (int n=0; n<12; n++){ if ((n==6) && ((rb+startingPRB) == (frame_parms->N_RB_DL>>1)) && ((frame_parms->N_RB_DL & 1) == 1)) { // if number RBs in bandwidth is odd and current PRB contains DC, we need to recalculate the offset when n=6 (for second half PRB) diff --git a/openair1/SCHED_NR/phy_procedures_nr_common.c b/openair1/SCHED_NR/phy_procedures_nr_common.c index e127e64e3e..1a0a02f22d 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_common.c +++ b/openair1/SCHED_NR/phy_procedures_nr_common.c @@ -32,15 +32,8 @@ #include "sched_nr.h" - - - - nr_subframe_t nr_slot_select(nfapi_nr_config_request_t *cfg,unsigned char slot) { if (cfg->subframe_config.duplex_mode.value == FDD) return(SF_DL); } - - - diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index a77c828625..762878a9b5 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -112,9 +112,8 @@ int nr_get_ssb_start_symbol(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *f void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp) { - int start_rb = cfg->sch_config.n_ssb_crb.value / (1<subframe_config.numerology_index_mu.value); - fp->ssb_start_subcarrier = 12 * start_rb + cfg->sch_config.ssb_subcarrier_offset.value; - LOG_D(PHY, "SSB first subcarrier %d (%d,%d)\n", fp->ssb_start_subcarrier,start_rb,cfg->sch_config.ssb_subcarrier_offset.value); + fp->ssb_start_subcarrier = (12 * cfg->sch_config.n_ssb_crb.value + cfg->sch_config.ssb_subcarrier_offset.value)/(1<subframe_config.numerology_index_mu.value); + LOG_D(PHY, "SSB first subcarrier %d (%d,%d)\n", fp->ssb_start_subcarrier,cfg->sch_config.n_ssb_crb.value,cfg->sch_config.ssb_subcarrier_offset.value); } void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 9e4027ab13..1daaf90cd6 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -52,7 +52,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ if(scheduled_response != NULL){ // Note: we have to handle the thread IDs for this. To be revisited completely. NR_UE_PDCCH *pdcch_vars2 = PHY_vars_UE_g[module_id][cc_id]->pdcch_vars[0][0]; - NR_UE_DLSCH_t *dlsch0 = PHY_vars_UE_g[module_id][cc_id]->dlsch[0][0]; + NR_UE_DLSCH_t *dlsch0 = PHY_vars_UE_g[module_id][cc_id]->dlsch[0][0][0]; NR_UE_ULSCH_t *ulsch0 = PHY_vars_UE_g[module_id][cc_id]->ulsch[0]; NR_DL_FRAME_PARMS frame_parms = PHY_vars_UE_g[module_id][cc_id]->frame_parms; PRACH_RESOURCES_t *prach_resources = PHY_vars_UE_g[module_id][cc_id]->prach_resources[0]; @@ -254,3 +254,4 @@ int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config){ return 0; } + diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 02384f95d2..26516d6e49 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -56,7 +56,7 @@ //#define DEBUG_PHY_PROC #define NR_PDCCH_SCHED -//#define NR_PDCCH_SCHED_DEBUG +#define NR_PDCCH_SCHED_DEBUG //#define NR_PUCCH_SCHED //#define NR_PUCCH_SCHED_DEBUG @@ -3237,11 +3237,13 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * #ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_dci_decoding_procedure with eNB_id=%d (n_RB_ULBWP=%d, n_RB_DLBWP=%d, searchSpaceType=%d, nb_searchspace_active=%d, nb_coreset_active=%d) -> dci_cnt=%d\n", - eNB_id,n_RB_ULBWP,n_RB_DLBWP,searchSpaceType, + printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_dci_decoding_procedure with eNB_id=%d (n_RB_ULBWP=%d, n_RB_DLBWP=%d, searchSpaceType=%d, nb_searchspace_active=%d, nb_coreset_active=%d)\n", + eNB_id, + pdcch_vars2->n_RB_BWP[nb_searchspace_active], + pdcch_vars2->n_RB_BWP[nb_searchspace_active], + searchSpaceType, nb_searchspace_active, - nb_coreset_active, - dci_cnt); + nb_coreset_active); #endif @@ -3348,14 +3350,14 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * ue->dci_ind.dci_list[i].dci_format = dci_alloc_rx[i].format; ue->dci_ind.dci_list[i].n_CCE = dci_alloc_rx[i].firstCCE; ue->dci_ind.dci_list[i].N_CCE = (int)dci_alloc_rx[i].L; - ue->dci_ind.number_of_dcis = ue->dci_ind.number_of_dcis + 1; - memcpy(&ue->dci_ind.dci_list[i].dci, &nr_dci_info_extracted, sizeof(fapi_nr_dci_pdu_rel15_t) ); + memcpy(&ue->dci_ind.dci_list[i].dci, &nr_dci_info_extracted, sizeof(fapi_nr_dci_pdu_rel15_t) ); - // TODO: check where should we send up this message. - //ue->if_inst->dl_indication(&ue->dl_indication); - } // end for loop dci_cnt + // TODO: check where should we send up this message. + ue->if_inst->dl_indication(&ue->dl_indication); + + #if UE_TIMING_TRACE stop_meas(&ue->dlsch_rx_pdcch_stats); #endif diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 2bb80148f2..1c2b2305d6 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -36,14 +36,14 @@ #include "PHY/defs_nr_common.h" #include "PHY/defs_nr_UE.h" #include "PHY/defs_gNB.h" +#include "PHY/INIT/phy_init.h" #include "PHY/NR_REFSIG/refsig_defs_ue.h" #include "PHY/NR_REFSIG/nr_mod_table.h" #include "PHY/MODULATION/modulation_eNB.h" #include "PHY/MODULATION/modulation_UE.h" -#include "PHY/INIT/phy_init.h" #include "PHY/NR_TRANSPORT/nr_transport.h" -#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" +#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "SCHED_NR/sched_nr.h" @@ -52,626 +52,617 @@ //#include "UTIL/LISTS/list.h" //#include "common/ran_context.h" +//#define DEBUG_DLSCHSIM + PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; - double cpuf; // dummy functions -int nfapi_mode=0; +int nfapi_mode = 0; int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { - return(0); + return (0); } int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) { - return(0); + return (0); } int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) { - return(0); + return (0); } int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) { - return(0); + return (0); } int oai_nfapi_nr_dl_config_req(nfapi_nr_dl_config_request_t *dl_config_req) { - return(0); + return (0); } -uint32_t from_nrarfcn(int nr_bandP,uint32_t dl_earfcn) { - return(0); +uint32_t from_nrarfcn(int nr_bandP, uint32_t dl_earfcn) { + return (0); } int32_t get_uldl_offset(int eutra_bandP) { - return(0); + return (0); } -NR_IF_Module_t *NR_IF_Module_init(int Mod_id) { - return(NULL); +NR_IF_Module_t * +NR_IF_Module_init(int Mod_id) { + return (NULL); } -void exit_function(const char *file, const char *function, const int line,const char *s) { - const char *msg= s==NULL ? "no comment": s; - printf("Exiting at: %s:%d %s(), %s\n", file, line, function, msg); - exit(-1); +void exit_function(const char *file, const char *function, const int line, + const char *s) { + const char *msg = s == NULL ? "no comment" : s; + printf("Exiting at: %s:%d %s(), %s\n", file, line, function, msg); + exit(-1); } // needed for some functions -PHY_VARS_NR_UE *PHY_vars_UE_g[1][1]= {{NULL}}; -uint16_t n_rnti=0x1234; +PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } }; +uint16_t n_rnti = 0x1234; -char quantize(double D,double x,unsigned char B) { - double qxd; - short maxlev; - qxd = floor(x/D); - maxlev = 1<<(B-1);//(char)(pow(2,B-1)); +char quantize(double D, double x, unsigned char B) { + double qxd; + short maxlev; + qxd = floor(x / D); + maxlev = 1 << (B - 1); //(char)(pow(2,B-1)); - //printf("x=%f,qxd=%f,maxlev=%d\n",x,qxd, maxlev); + //printf("x=%f,qxd=%f,maxlev=%d\n",x,qxd, maxlev); - if (qxd <= -maxlev) - qxd = -maxlev; - else if (qxd >= maxlev) - qxd = maxlev-1; + if (qxd <= -maxlev) + qxd = -maxlev; + else if (qxd >= maxlev) + qxd = maxlev - 1; - return((char)qxd); + return ((char) qxd); } int main(int argc, char **argv) { - char c; - int i; //,j,l,aa; - double SNR,SNR_lin,snr0=-2.0,snr1=2.0; - double snr_step = 0.1; - uint8_t snr1set=0; - int **txdata; - double **s_re,**s_im,**r_re,**r_im; - // int sync_pos, sync_pos_slot; - // FILE *rx_frame_file; - FILE *output_fd = NULL; - uint8_t write_output_file=0; - // int subframe_offset; - // char fname[40], vname[40]; - int trial,n_trials=1,n_errors=0,n_false_positive=0; - uint8_t transmission_mode = 1,n_tx=1,n_rx=1; - uint16_t Nid_cell=0; - channel_desc_t *gNB2UE; - uint8_t extended_prefix_flag=0; - int8_t interf1=-21,interf2=-21; - FILE *input_fd=NULL,*pbch_file_fd=NULL; - char input_val_str[50],input_val_str2[50]; - //uint16_t NB_RB=25; - SCM_t channel_model=AWGN;//Rayleigh1_anticorr; - uint8_t N_RB_DL=106,mu=1; - unsigned char frame_type = 0; - unsigned char pbch_phase = 0; - int frame=0,subframe=0; - int frame_length_complex_samples; - //int frame_length_complex_samples_no_prefix; - NR_DL_FRAME_PARMS *frame_parms; - //nfapi_nr_config_request_t *gNB_config; - uint8_t Kmimo; - uint32_t Nsoft; - double sigma; - unsigned char qbits=8; - int ret; - int run_initial_sync=0; - int loglvl=OAILOG_WARNING; - float target_error_rate = 0.01; + char c; + int i; //,j,l,aa; + double SNR, SNR_lin, snr0 = -2.0, snr1 = 2.0; + double snr_step = 0.1; + uint8_t snr1set = 0; + int **txdata; + double **s_re, **s_im, **r_re, **r_im; + // int sync_pos, sync_pos_slot; + // FILE *rx_frame_file; + FILE *output_fd = NULL; + uint8_t write_output_file = 0; + // int subframe_offset; + // char fname[40], vname[40]; + int trial, n_trials = 1, n_errors = 0, n_false_positive = 0; + uint8_t transmission_mode = 1, n_tx = 1, n_rx = 1; + uint16_t Nid_cell = 0; + channel_desc_t *gNB2UE; + uint8_t extended_prefix_flag = 0; + int8_t interf1 = -21, interf2 = -21; + FILE *input_fd = NULL, *pbch_file_fd = NULL; + //char input_val_str[50],input_val_str2[50]; + //uint16_t NB_RB=25; + SCM_t channel_model = AWGN; //Rayleigh1_anticorr; + uint8_t N_RB_DL = 106, mu = 1; + unsigned char frame_type = 0; + unsigned char pbch_phase = 0; + int frame = 0, subframe = 0; + int frame_length_complex_samples; + //int frame_length_complex_samples_no_prefix; + NR_DL_FRAME_PARMS *frame_parms; + //nfapi_nr_config_request_t *gNB_config; + uint8_t Kmimo = 0; + uint32_t Nsoft = 0; + double sigma; + unsigned char qbits = 8; + int ret; + //int run_initial_sync=0; + int loglvl = OAILOG_WARNING; + float target_error_rate = 0.01; - uint16_t nb_symb_sch =12; - uint16_t nb_rb = 50; - uint8_t Imcs=9; + uint16_t nb_symb_sch = 12; + uint16_t nb_rb = 50; + uint8_t Imcs = 9; - cpuf = get_cpu_freq_GHz(); + cpuf = get_cpu_freq_GHz(); - if ( load_configmodule(argc,argv) == 0) { - exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); - } + if (load_configmodule(argc, argv) == 0) { + exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); + } - //logInit(); - randominit(0); + //logInit(); + randominit(0); - while ((c = getopt (argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:N:F:R:P:")) != -1) { - switch (c) { - case 'f': - write_output_file=1; - output_fd = fopen(optarg,"w"); + while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:N:F:R:P:")) != -1) { + switch (c) { + case 'f': + write_output_file = 1; + output_fd = fopen(optarg, "w"); - if (output_fd==NULL) { - printf("Error opening %s\n",optarg); - exit(-1); - } + if (output_fd == NULL) { + printf("Error opening %s\n", optarg); + exit(-1); + } - break; + break; - case 'd': - frame_type = 1; - break; + case 'd': + frame_type = 1; + break; - case 'g': - switch((char)*optarg) { - case 'A': - channel_model=SCM_A; - break; + case 'g': + switch ((char) *optarg) { + case 'A': + channel_model = SCM_A; + break; - case 'B': - channel_model=SCM_B; - break; + case 'B': + channel_model = SCM_B; + break; - case 'C': - channel_model=SCM_C; - break; + case 'C': + channel_model = SCM_C; + break; - case 'D': - channel_model=SCM_D; - break; + case 'D': + channel_model = SCM_D; + break; - case 'E': - channel_model=EPA; - break; + case 'E': + channel_model = EPA; + break; - case 'F': - channel_model=EVA; - break; + case 'F': + channel_model = EVA; + break; - case 'G': - channel_model=ETU; - break; + case 'G': + channel_model = ETU; + break; - default: - msg("Unsupported channel model!\n"); - exit(-1); - } + default: + msg("Unsupported channel model!\n"); + exit(-1); + } - break; + break; - case 'i': - interf1=atoi(optarg); - break; + case 'i': + interf1 = atoi(optarg); + break; - case 'j': - interf2=atoi(optarg); - break; + case 'j': + interf2 = atoi(optarg); + break; - case 'n': - n_trials = atoi(optarg); - break; + case 'n': + n_trials = atoi(optarg); + break; - case 's': - snr0 = atof(optarg); - msg("Setting SNR0 to %f\n",snr0); - break; + case 's': + snr0 = atof(optarg); + msg("Setting SNR0 to %f\n", snr0); + break; - case 'S': - snr1 = atof(optarg); - snr1set=1; - msg("Setting SNR1 to %f\n",snr1); - break; + case 'S': + snr1 = atof(optarg); + snr1set = 1; + msg("Setting SNR1 to %f\n", snr1); + break; - case 'p': - extended_prefix_flag=1; - break; + case 'p': + extended_prefix_flag = 1; + break; - /* - case 'r': - ricean_factor = pow(10,-.1*atof(optarg)); - if (ricean_factor>1) { - printf("Ricean factor must be between 0 and 1\n"); - exit(-1); - } - break; - */ - - case 'y': - n_tx=atoi(optarg); + /* + case 'r': + ricean_factor = pow(10,-.1*atof(optarg)); + if (ricean_factor>1) { + printf("Ricean factor must be between 0 and 1\n"); + exit(-1); + } + break; + */ - if ((n_tx==0) || (n_tx>2)) { - msg("Unsupported number of tx antennas %d\n",n_tx); - exit(-1); - } + case 'y': + n_tx = atoi(optarg); - break; + if ((n_tx == 0) || (n_tx > 2)) { + msg("Unsupported number of tx antennas %d\n", n_tx); + exit(-1); + } - case 'z': - n_rx=atoi(optarg); + break; - if ((n_rx==0) || (n_rx>2)) { - msg("Unsupported number of rx antennas %d\n",n_rx); - exit(-1); - } + case 'z': + n_rx = atoi(optarg); - break; + if ((n_rx == 0) || (n_rx > 2)) { + msg("Unsupported number of rx antennas %d\n", n_rx); + exit(-1); + } - case 'N': - Nid_cell = atoi(optarg); - break; + break; - case 'R': - N_RB_DL = atoi(optarg); - break; + case 'N': + Nid_cell = atoi(optarg); + break; - case 'F': - input_fd = fopen(optarg,"r"); + case 'R': + N_RB_DL = atoi(optarg); + break; - if (input_fd==NULL) { - printf("Problem with filename %s\n",optarg); - exit(-1); - } + case 'F': + input_fd = fopen(optarg, "r"); - break; + if (input_fd == NULL) { + printf("Problem with filename %s\n", optarg); + exit(-1); + } - case 'P': - pbch_phase = atoi(optarg); + break; - if (pbch_phase>3) - printf("Illegal PBCH phase (0-3) got %d\n",pbch_phase); + case 'P': + pbch_phase = atoi(optarg); - break; + if (pbch_phase > 3) + printf("Illegal PBCH phase (0-3) got %d\n", pbch_phase); - case 'm': - Imcs = atoi(optarg); - break; + break; - case 'l': - nb_symb_sch = atoi(optarg); - break; - - case 'r': - nb_rb = atoi(optarg); - break; - - default: - case 'h': - printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", - argv[0]); - printf("-h This message\n"); - printf("-p Use extended prefix mode\n"); - printf("-d Use TDD\n"); - printf("-n Number of frames to simulate\n"); - printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); - printf("-S Ending SNR, runs from SNR0 to SNR1\n"); - printf("-t Delay spread for multipath channel\n"); - printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n"); - 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("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); - printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); - printf("-N Nid_cell\n"); - printf("-R N_RB_DL\n"); - 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 Input filename (.txt format) for RX conformance testing\n"); - exit (-1); - break; - } - } + case 'm': + Imcs = atoi(optarg); + break; - logInit(); - set_glog(loglvl); - T_stdout = 1; + case 'l': + nb_symb_sch = atoi(optarg); + break; - if (snr1set==0) - snr1 = snr0+10; + case 'r': + nb_rb = atoi(optarg); + break; - gNB2UE = new_channel_desc_scm(n_tx, - n_rx, - channel_model, - 61.44e6, //N_RB2sampling_rate(N_RB_DL), - 40e6, //N_RB2channel_bandwidth(N_RB_DL), - 0, - 0, - 0); + case 'x': + transmission_mode = atoi(optarg); + break; - if (gNB2UE==NULL) { - msg("Problem generating channel model. Exiting.\n"); - exit(-1); - } + default: + case 'h': + printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); + printf("-h This message\n"); + printf("-p Use extended prefix mode\n"); + printf("-d Use TDD\n"); + printf("-n Number of frames to simulate\n"); + printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); + printf("-S Ending SNR, runs from SNR0 to SNR1\n"); + printf("-t Delay spread for multipath channel\n"); + printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n"); + 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("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); + printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + printf("-N Nid_cell\n"); + printf("-R N_RB_DL\n"); + 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 Input filename (.txt format) for RX conformance testing\n"); + exit(-1); + break; + } + } - RC.gNB = (PHY_VARS_gNB ** *) malloc(sizeof(PHY_VARS_gNB **)); - RC.gNB[0] = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *)); - RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB)); - gNB = RC.gNB[0][0]; - //gNB_config = &gNB->gNB_config; - frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) - frame_parms->nb_antennas_tx = n_tx; - frame_parms->nb_antennas_rx = n_rx; - frame_parms->N_RB_DL = N_RB_DL; - crcTableInit(); - nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu); - phy_init_nr_gNB(gNB,0,0); - //init_eNB_afterRU(); - frame_length_complex_samples = frame_parms->samples_per_subframe; - //frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP; - s_re = malloc(2*sizeof(double *)); - s_im = malloc(2*sizeof(double *)); - r_re = malloc(2*sizeof(double *)); - r_im = malloc(2*sizeof(double *)); - txdata = malloc(2*sizeof(int *)); + logInit(); + set_glog(loglvl); + T_stdout = 1; - for (i=0; i<2; i++) { - s_re[i] = malloc(frame_length_complex_samples*sizeof(double)); - bzero(s_re[i],frame_length_complex_samples*sizeof(double)); - s_im[i] = malloc(frame_length_complex_samples*sizeof(double)); - bzero(s_im[i],frame_length_complex_samples*sizeof(double)); - r_re[i] = malloc(frame_length_complex_samples*sizeof(double)); - bzero(r_re[i],frame_length_complex_samples*sizeof(double)); - r_im[i] = malloc(frame_length_complex_samples*sizeof(double)); - bzero(r_im[i],frame_length_complex_samples*sizeof(double)); - txdata[i] = malloc(frame_length_complex_samples*sizeof(int)); - bzero(r_re[i],frame_length_complex_samples*sizeof(int)); - } + if (snr1set == 0) + snr1 = snr0 + 10; - if (pbch_file_fd!=NULL) { - load_pbch_desc(pbch_file_fd); - } + gNB2UE = new_channel_desc_scm(n_tx, n_rx, channel_model, 61.44e6, //N_RB2sampling_rate(N_RB_DL), + 40e6, //N_RB2channel_bandwidth(N_RB_DL), + 0, 0, 0); - /* for (int k=0; k<2; k++) { - // Create transport channel structures for 2 transport blocks (MIMO) - for (i=0; i<2; i++) { - gNB->dlsch[k][i] = new_gNB_dlsch(Kmimo,8,Nsoft,0,frame_parms,gNB_config); + if (gNB2UE == NULL) { + msg("Problem generating channel model. Exiting.\n"); + exit(-1); + } - if (!gNB->dlsch[k][i]) { - printf("Can't get eNB dlsch structures\n"); - exit(-1); - } - gNB->dlsch[k][i]->Nsoft = 10; - gNB->dlsch[k][i]->rnti = n_rnti+k; - } - }*/ - //configure UE - UE = malloc(sizeof(PHY_VARS_NR_UE)); - memcpy(&UE->frame_parms,frame_parms,sizeof(NR_DL_FRAME_PARMS)); + RC.gNB = (PHY_VARS_gNB ** *) malloc(sizeof(PHY_VARS_gNB **)); + RC.gNB[0] = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *)); + RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB)); + gNB = RC.gNB[0][0]; + //gNB_config = &gNB->gNB_config; + frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) + frame_parms->nb_antennas_tx = n_tx; + frame_parms->nb_antennas_rx = n_rx; + frame_parms->N_RB_DL = N_RB_DL; + crcTableInit(); + nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell); + phy_init_nr_gNB(gNB, 0, 0); + //init_eNB_afterRU(); + frame_length_complex_samples = frame_parms->samples_per_subframe; + //frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP; + s_re = malloc(2 * sizeof(double *)); + s_im = malloc(2 * sizeof(double *)); + r_re = malloc(2 * sizeof(double *)); + r_im = malloc(2 * sizeof(double *)); + txdata = malloc(2 * sizeof(int *)); - //phy_init_nr_top(frame_parms); - if (init_nr_ue_signal(UE, 1, 0) != 0) { - printf("Error at UE NR initialisation\n"); - exit(-1); - } + for (i = 0; i < 2; i++) { + s_re[i] = malloc(frame_length_complex_samples * sizeof(double)); + bzero(s_re[i], frame_length_complex_samples * sizeof(double)); + s_im[i] = malloc(frame_length_complex_samples * sizeof(double)); + bzero(s_im[i], frame_length_complex_samples * sizeof(double)); + r_re[i] = malloc(frame_length_complex_samples * sizeof(double)); + bzero(r_re[i], frame_length_complex_samples * sizeof(double)); + r_im[i] = malloc(frame_length_complex_samples * sizeof(double)); + bzero(r_im[i], frame_length_complex_samples * sizeof(double)); + txdata[i] = malloc(frame_length_complex_samples * sizeof(int)); + bzero(r_re[i], frame_length_complex_samples * sizeof(int)); + } - //nr_init_frame_parms_ue(&UE->frame_parms); - //init_nr_ue_transport(UE, 0); - for (int sf = 0; sf < 2; sf++) { - for (i=0; i<2; i++) { - UE->dlsch[sf][0][i] = new_nr_ue_dlsch(Kmimo,8,Nsoft,5,N_RB_DL,0); + if (pbch_file_fd != NULL) { + load_pbch_desc(pbch_file_fd); + } - if (!UE->dlsch[sf][0][i]) { - printf("Can't get ue dlsch structures\n"); - exit(-1); - } + /* for (int k=0; k<2; k++) { + // Create transport channel structures for 2 transport blocks (MIMO) + for (i=0; i<2; i++) { + gNB->dlsch[k][i] = new_gNB_dlsch(Kmimo,8,Nsoft,0,frame_parms,gNB_config); - UE->dlsch[sf][0][i]->rnti = n_rnti; - } - } + if (!gNB->dlsch[k][i]) { + printf("Can't get eNB dlsch structures\n"); + exit(-1); + } + gNB->dlsch[k][i]->Nsoft = 10; + gNB->dlsch[k][i]->rnti = n_rnti+k; + } + }*/ + //configure UE + UE = malloc(sizeof(PHY_VARS_NR_UE)); + memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS)); - UE->dlsch_SI[0] = new_nr_ue_dlsch(1,1,Nsoft,5,N_RB_DL,0); - UE->dlsch_ra[0] = new_nr_ue_dlsch(1,1,Nsoft,5,N_RB_DL,0); - unsigned char harq_pid = 0; //dlsch->harq_ids[subframe]; - NR_gNB_DLSCH_t *dlsch = gNB->dlsch[0][0]; - nfapi_nr_dl_config_dlsch_pdu_rel15_t *rel15 = &dlsch->harq_processes[harq_pid]->dlsch_pdu.dlsch_pdu_rel15; - time_stats_t *rm_stats; - time_stats_t *te_stats; - time_stats_t *i_stats; - uint8_t is_crnti; - uint8_t llr8_flag; - unsigned int TBS = 8424; - unsigned int available_bits; - uint8_t nb_re_dmrs = 6; - uint16_t length_dmrs = 1; - unsigned char mod_order; - uint8_t Nl=1; - uint8_t rvidx = 0; - dlsch->rnti =1; - /*dlsch->harq_processes[0]->mcs = Imcs; - dlsch->harq_processes[0]->rvidx = rvidx;*/ - //printf("dlschsim harqid %d nb_rb %d, mscs %d\n",dlsch->harq_ids[subframe], - // dlsch->harq_processes[0]->nb_rb,dlsch->harq_processes[0]->mcs,dlsch->harq_processes[0]->Nl); - mod_order = nr_get_Qm(Imcs,1); - available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order,1); - TBS= nr_compute_tbs(Imcs,nb_rb,nb_symb_sch,nb_re_dmrs,length_dmrs,Nl); - printf("available bits %d TBS %d mod_order %d\n",available_bits, TBS, mod_order); - //dlsch->harq_ids[subframe]= 0; - rel15->n_prb = nb_rb; - rel15->nb_symbols = nb_symb_sch; - rel15->modulation_order = mod_order; - rel15->nb_layers = Nl; - rel15->nb_re_dmrs = nb_re_dmrs; - rel15->transport_block_size = TBS; - double *modulated_input = malloc16(sizeof(double) * 16*68*384); - short *channel_output_fixed = malloc16(sizeof( short) *16* 68*384); - short *channel_output_uncoded = malloc16(sizeof(unsigned short) *16* 68*384); - double errors_bit_uncoded=0; - unsigned char *estimated_output; - unsigned char *estimated_output_bit; - unsigned char *test_input_bit; - unsigned int errors_bit =0; - test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16*68*384); - estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16*68*384); - estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16*68*384); - NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[UE->current_thread_id[subframe]][0][0]; - NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid]; - harq_process->mcs = Imcs; - harq_process->Nl = Nl; - harq_process->nb_rb = nb_rb; - harq_process->Qm = mod_order; - harq_process->rvidx = rvidx; - printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm,nb_symb_sch); - unsigned char *test_input; - test_input=(unsigned char *)malloc16(sizeof(unsigned char) * TBS/8); + //phy_init_nr_top(frame_parms); + if (init_nr_ue_signal(UE, 1, 0) != 0) { + printf("Error at UE NR initialisation\n"); + exit(-1); + } - for (i=0; iframe_parms); + //init_nr_ue_transport(UE, 0); + for (int sf = 0; sf < 2; sf++) { + for (i = 0; i < 2; i++) { + UE->dlsch[sf][0][i] = new_nr_ue_dlsch(Kmimo, 8, Nsoft, 5, N_RB_DL, + 0); - estimated_output = harq_process->b; + if (!UE->dlsch[sf][0][i]) { + printf("Can't get ue dlsch structures\n"); + exit(-1); + } - /*for (int i=0; idlsch[sf][0][i]->rnti = n_rnti; + } + } - //printf("crc32: [0]->0x%08x\n",crc24c(test_input, 32)); + UE->dlsch_SI[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0); + UE->dlsch_ra[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0); + unsigned char harq_pid = 0; //dlsch->harq_ids[subframe]; + NR_gNB_DLSCH_t *dlsch = gNB->dlsch[0][0]; + nfapi_nr_dl_config_dlsch_pdu_rel15_t *rel15 = &dlsch->harq_processes[harq_pid]->dlsch_pdu.dlsch_pdu_rel15; + //time_stats_t *rm_stats, *te_stats, *i_stats; + uint8_t is_crnti = 0, llr8_flag = 0; + unsigned int TBS = 8424; + unsigned int available_bits; + uint8_t nb_re_dmrs = 6; + uint16_t length_dmrs = 1; + unsigned char mod_order; + uint8_t Nl = 1; + uint8_t rvidx = 0; + dlsch->rnti = 1; + /*dlsch->harq_processes[0]->mcs = Imcs; + dlsch->harq_processes[0]->rvidx = rvidx;*/ + //printf("dlschsim harqid %d nb_rb %d, mscs %d\n",dlsch->harq_ids[subframe], + // dlsch->harq_processes[0]->nb_rb,dlsch->harq_processes[0]->mcs,dlsch->harq_processes[0]->Nl); + mod_order = nr_get_Qm(Imcs, 1); + available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); + TBS = nr_compute_tbs(Imcs, nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, Nl); + printf("available bits %d TBS %d mod_order %d\n", available_bits, TBS, mod_order); + //dlsch->harq_ids[subframe]= 0; + rel15->n_prb = nb_rb; + rel15->nb_symbols = nb_symb_sch; + rel15->modulation_order = mod_order; + rel15->nb_layers = Nl; + rel15->nb_re_dmrs = nb_re_dmrs; + rel15->transport_block_size = TBS; + double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); + short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); + short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384); + double errors_bit_uncoded = 0; + unsigned char *estimated_output; + unsigned char *estimated_output_bit; + unsigned char *test_input_bit; + unsigned int errors_bit = 0; + test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[UE->current_thread_id[subframe]][0][0]; + NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid]; + harq_process->mcs = Imcs; + harq_process->Nl = Nl; + harq_process->nb_rb = nb_rb; + harq_process->Qm = mod_order; + harq_process->rvidx = rvidx; + printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm, nb_symb_sch); + unsigned char *test_input; + test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8); - // generate signal - if (input_fd==NULL) { - nr_dlsch_encoding(test_input, - subframe, - dlsch, - frame_parms); - } + for (i = 0; i < TBS / 8; i++) + test_input[i] = (unsigned char) rand(); - for (SNR=snr0; SNRb; +#ifdef DEBUG_DLSCHSIM + for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%d \n",test_input[i]); #endif - //if (i<16) - // printf("encoder output f[%d] = %d\n",i,dlsch->harq_processes[0]->f[i]); - if (dlsch->harq_processes[0]->f[i]==0) - modulated_input[i]=1.0;///sqrt(2); //QPSK - else - modulated_input[i]=-1.0;///sqrt(2); + /*for (int i=0; i0x%08x\n",crc24c(test_input, 32)); + // generate signal + if (input_fd == NULL) { + nr_dlsch_encoding(test_input, subframe, dlsch, frame_parms); + } - //channel_output_fixed[i] = (char)quantize(1,channel_output_fixed[i],qbits); + for (SNR = snr0; SNR < snr1; SNR += snr_step) { + n_errors = 0; + n_false_positive = 0; - //if (i<16) printf("channel_output_fixed[%d] = %d\n",i,channel_output_fixed[i]); - - //Uncoded BER - if (channel_output_fixed[i]<0) - channel_output_uncoded[i]=1; //QPSK demod - else - channel_output_uncoded[i]=0; - - if (channel_output_uncoded[i] != dlsch->harq_processes[harq_pid]->f[i]) - errors_bit_uncoded = errors_bit_uncoded + 1; - } - - //if (errors_bit_uncoded>10) - //printf("errors bits uncoded %f\n", errors_bit_uncoded); + for (trial = 0; trial < n_trials; trial++) { + errors_bit_uncoded = 0; + for (i = 0; i < available_bits; i++) { #ifdef DEBUG_CODER - printf("\n"); - exit(-1); + if ((i&0xf)==0) + printf("\ne %d..%d: ",i,i+15); #endif - ret = nr_dlsch_decoding(UE, - channel_output_fixed, - &UE->frame_parms, - dlsch0_ue, - dlsch0_ue->harq_processes[0], - frame, - nb_symb_sch, - subframe, - harq_pid, - is_crnti, - llr8_flag); - if (ret>dlsch0_ue->max_ldpc_iterations) - n_errors++; + //if (i<16) + // printf("encoder output f[%d] = %d\n",i,dlsch->harq_processes[0]->f[i]); + if (dlsch->harq_processes[0]->f[i] == 0) + modulated_input[i] = 1.0; ///sqrt(2); //QPSK + else + modulated_input[i] = -1.0; ///sqrt(2); - //count errors - errors_bit = 0; + //if (i<16) printf("modulated_input[%d] = %d\n",i,modulated_input[i]); + //SNR =10; + SNR_lin = pow(10, SNR / 10.0); + sigma = 1.0 / sqrt(2 * SNR_lin); + channel_output_fixed[i] = (short) quantize(sigma / 4.0 / 4.0, + modulated_input[i] + sigma * gaussdouble(0.0, 1.0), + qbits); + //channel_output_fixed[i] = (char)quantize8bit(sigma/4.0,(2.0*modulated_input[i]) - 1.0 + sigma*gaussdouble(0.0,1.0)); + //printf("llr[%d]=%d\n",i,channel_output_fixed[i]); + //printf("channel_output_fixed[%d]: %d\n",i,channel_output_fixed[i]); - for (i=0; i>(i&7); - test_input_bit[i] = (test_input[i/8]&(1<<(i&7)))>>(i&7); // Further correct for multiple segments + //channel_output_fixed[i] = (char)quantize(1,channel_output_fixed[i],qbits); - if (estimated_output_bit[i] != test_input_bit[i]) { - errors_bit++; - //printf("estimated bits error occurs @%d ",i); - } - } + //if (i<16) printf("channel_output_fixed[%d] = %d\n",i,channel_output_fixed[i]); - if (errors_bit>0) { - n_false_positive++; - if (n_trials == 1) - printf("\n errors_bit %d (trial %d)\n", errors_bit,trial); - } - } + //Uncoded BER + if (channel_output_fixed[i] < 0) + channel_output_uncoded[i] = 1; //QPSK demod + else + channel_output_uncoded[i] = 0; - printf("SNR %f, BLER %f (false positive %f)\n",SNR,(float)n_errors/(float)n_trials,(float)n_false_positive/(float)n_trials); + if (channel_output_uncoded[i] != dlsch->harq_processes[harq_pid]->f[i]) + errors_bit_uncoded = errors_bit_uncoded + 1; + } - if ((float)n_errors/(float)n_trials < target_error_rate) - break; - } + //if (errors_bit_uncoded>10) + //printf("errors bits uncoded %f\n", errors_bit_uncoded); +#ifdef DEBUG_CODER + printf("\n"); + exit(-1); +#endif + ret = nr_dlsch_decoding(UE, channel_output_fixed, &UE->frame_parms, + dlsch0_ue, dlsch0_ue->harq_processes[0], frame, nb_symb_sch, + subframe, harq_pid, is_crnti, llr8_flag); - /*LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1); - if (gNB->frame_parms.nb_antennas_tx>1) - LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1);*/ + if (ret > dlsch0_ue->max_ldpc_iterations) + n_errors++; - //TODO: loop over slots - /*for (aa=0; aaframe_parms.nb_antennas_tx; aa++) { - if (gNB_config->subframe_config.dl_cyclic_prefix_type.value == 1) { - PHY_ofdm_mod(gNB->common_vars.txdataF[aa], - txdata[aa], - frame_parms->ofdm_symbol_size, - 12, - frame_parms->nb_prefix_samples, - CYCLIC_PREFIX); - } else { - nr_normal_prefix_mod(gNB->common_vars.txdataF[aa], - txdata[aa], - 14, - frame_parms); - } - } + //count errors + errors_bit = 0; - LOG_M("txsig0.m","txs0", txdata[0],frame_length_complex_samples,1,1); - if (gNB->frame_parms.nb_antennas_tx>1) - LOG_M("txsig1.m","txs1", txdata[1],frame_length_complex_samples,1,1); + for (i = 0; i < TBS; i++) { + estimated_output_bit[i] = (dlsch0_ue->harq_processes[0]->b[i / 8] & (1 << (i & 7))) >> (i & 7); + test_input_bit[i] = (test_input[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments + + if (estimated_output_bit[i] != test_input_bit[i]) { + errors_bit++; + //printf("estimated bits error occurs @%d ",i); + } + } + + if (errors_bit > 0) { + n_false_positive++; + if (n_trials == 1) + printf("errors_bit %d (trial %d)\n", errors_bit, trial); + } + } + + printf("SNR %f, BLER %f (false positive %f)\n", SNR, + (float) n_errors / (float) n_trials, + (float) n_false_positive / (float) n_trials); + + if ((float) n_errors / (float) n_trials < target_error_rate) + break; + } + + /*LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1); + if (gNB->frame_parms.nb_antennas_tx>1) + LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1);*/ + + //TODO: loop over slots + /*for (aa=0; aaframe_parms.nb_antennas_tx; aa++) { + if (gNB_config->subframe_config.dl_cyclic_prefix_type.value == 1) { + PHY_ofdm_mod(gNB->common_vars.txdataF[aa], + txdata[aa], + frame_parms->ofdm_symbol_size, + 12, + frame_parms->nb_prefix_samples, + CYCLIC_PREFIX); + } else { + nr_normal_prefix_mod(gNB->common_vars.txdataF[aa], + txdata[aa], + 14, + frame_parms); + } + } + + LOG_M("txsig0.m","txs0", txdata[0],frame_length_complex_samples,1,1); + if (gNB->frame_parms.nb_antennas_tx>1) + LOG_M("txsig1.m","txs1", txdata[1],frame_length_complex_samples,1,1); - for (i=0; inb_antennas_tx; aa++) { - r_re[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)]); - r_im[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)+1]); - } - }*/ + for (i=0; inb_antennas_tx; aa++) { + r_re[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)]); + r_im[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)+1]); + } + }*/ - for (i=0; i<2; i++) { - printf("gNB %d\n",i); - free_gNB_dlsch(gNB->dlsch[0][i]); - printf("UE %d\n",i); - free_nr_ue_dlsch(UE->dlsch[UE->current_thread_id[subframe]][0][i]); - } + for (i = 0; i < 2; i++) { + printf("gNB %d\n", i); + free_gNB_dlsch(gNB->dlsch[0][i]); + printf("UE %d\n", i); + free_nr_ue_dlsch(UE->dlsch[UE->current_thread_id[subframe]][0][i]); + } - for (i=0; i<2; i++) { - free(s_re[i]); - free(s_im[i]); - free(r_re[i]); - free(r_im[i]); - free(txdata[i]); - } + for (i = 0; i < 2; i++) { + free(s_re[i]); + free(s_im[i]); + free(r_re[i]); + free(r_im[i]); + free(txdata[i]); + } - free(s_re); - free(s_im); - free(r_re); - free(r_im); - free(txdata); + free(s_re); + free(s_im); + free(r_re); + free(r_im); + free(txdata); - if (output_fd) - fclose(output_fd); + if (output_fd) + fclose(output_fd); - if (input_fd) - fclose(input_fd); + if (input_fd) + fclose(input_fd); - return(n_errors); + return (n_errors); } - - diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index f02180916e..f3a3219d71 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -622,7 +622,7 @@ int main(int argc, char **argv) uint32_t number_of_search_space_per_slot=1; uint32_t first_symbol_index=0; - uint32_t search_space_duration; // element of search space + uint32_t search_space_duration=0; // element of search space uint32_t coreset_duration; // element of coreset coreset_duration = num_symbols * number_of_search_space_per_slot; diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 9a9f882531..f71cb7d147 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -85,39 +85,41 @@ int main(int argc, char **argv) char c; - int i,l,aa; + int i,aa;//,l; double sigma2, sigma2_dB=10,SNR,snr0=-2.0,snr1=2.0; uint8_t snr1set=0; int **txdata; double **s_re,**s_im,**r_re,**r_im; - double iqim = 0.0; - unsigned char pbch_pdu[6]; + //double iqim = 0.0; + //unsigned char pbch_pdu[6]; // int sync_pos, sync_pos_slot; // FILE *rx_frame_file; FILE *output_fd = NULL; uint8_t write_output_file=0; //int result; - int freq_offset; + //int freq_offset; // int subframe_offset; // char fname[40], vname[40]; - int trial,n_trials=1,n_errors,n_errors_payload; + int trial,n_trials=1,n_errors=0,n_errors_payload=0; uint8_t transmission_mode = 1,n_tx=1,n_rx=1; uint16_t Nid_cell=0; channel_desc_t *gNB2UE; - uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0; + uint8_t extended_prefix_flag=0; int8_t interf1=-21,interf2=-21; FILE *input_fd=NULL,*pbch_file_fd=NULL; - char input_val_str[50],input_val_str2[50]; - uint8_t frame_mod4,num_pdcch_symbols = 0; + //uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0; + //char input_val_str[50],input_val_str2[50]; + //uint8_t frame_mod4,num_pdcch_symbols = 0; + //double pbch_sinr; + //int pbch_tx_ant; SCM_t channel_model=AWGN;//Rayleigh1_anticorr; - double pbch_sinr; - int pbch_tx_ant; + int N_RB_DL=273,mu=1; unsigned char frame_type = 0; @@ -355,7 +357,7 @@ int main(int argc, char **argv) frame_parms->N_RB_DL = N_RB_DL; frame_parms->N_RB_UL = N_RB_DL; - nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu); + nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell); phy_init_nr_gNB(gNB,0,0); double fs,bw; @@ -474,7 +476,7 @@ int main(int argc, char **argv) frame_length_complex_samples, input_fd) != frame_length_complex_samples) { printf("error reading from file\n"); - exit(-1); + //exit(-1); } } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 24662aaa7c..f34000bc98 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -127,5 +127,8 @@ void nr_ue_process_mac_pdu( uint8_t *pduP, uint16_t mac_pdu_len, uint8_t eNB_index); + +int8_t nr_ue_process_dlsch(module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_indication_t *dci_ind, void *pduP, uint32_t pdu_len); + #endif -/** @}*/ \ No newline at end of file +/** @}*/ diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 157ce9d84d..44f1cf05ea 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -95,7 +95,7 @@ int8_t nr_ue_process_dlsch(module_id_t module_id, int cc_id, uint8_t gNB_index, ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = 0; ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.tpmi = 0; ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.n_dmrs_cdm_groups = 0; - ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.dmrs_ports[4] = 0; + for (int i=0;i<4;i++) ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.dmrs_ports[i]=0; ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.n_front_load_symb = 0; //ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.srs_config = 0; ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.csi_reportTriggerSize = 0; @@ -125,7 +125,7 @@ int8_t nr_ue_process_dlsch(module_id_t module_id, int cc_id, uint8_t gNB_index, ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pucch_GroupHopping = phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_group_hopping; ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.hoppingId = phy_config->config_req.ul_bwp_common.pucch_config_common.hopping_id; ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_nominal = phy_config->config_req.ul_bwp_common.pucch_config_common.p0_nominal; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.deltaF_PUCCH_f[NUMBER_PUCCH_FORMAT_NR] = 0; + for (int i=0;iul_config_list[ul_config->number_pdus].pucch_config_pdu.deltaF_PUCCH_f[i] = 0; ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_PUCCH_Id = 0; /* INTEGER (1..8) */ ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_PUCCH_Value = 0; ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.twoPUCCH_PC_AdjustmentStates = 0; @@ -180,14 +180,14 @@ int8_t nr_ue_process_dlsch(module_id_t module_id, int cc_id, uint8_t gNB_index, ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pucch_GroupHopping = phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_group_hopping; ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.hoppingId = phy_config->config_req.ul_bwp_common.pucch_config_common.hopping_id; ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_nominal = phy_config->config_req.ul_bwp_common.pucch_config_common.p0_nominal; - ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.deltaF_PUCCH_f[NUMBER_PUCCH_FORMAT_NR] = 0; + for (int i=0;iul_config_list[ul_config->number_pdus].pucch_config_pdu.deltaF_PUCCH_f[i] = 0; ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_PUCCH_Id = 0; /* INTEGER (1..8) */ ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_PUCCH_Value = 0; ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.twoPUCCH_PC_AdjustmentStates = 0; } if(mac->if_module != NULL && mac->if_module->ul_indication != NULL){ - mac->if_module->ul_indication(&mac->scheduled_response); + mac->if_module->dl_indication(&mac->scheduled_response); } return 0; } @@ -659,9 +659,15 @@ NR_UE_L2_STATE_t nr_ue_scheduler( dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15 = mac->type0_pdcch_dci_config; dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI; - dl_config->number_pdus = dl_config->number_pdus + 1; dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.rnti = 0xaaaa; // to be set + dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP = 106; // to be set + /* + printf("nr_ue_scheduler Type0 PDCCH with rnti %x, BWP %d\n", + dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.rnti, + dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP); + */ + dl_config->number_pdus = dl_config->number_pdus + 1; } if(search_space_mask & type0a_pdcch){ @@ -1301,9 +1307,9 @@ printf("\n>>> nr_ue_process_dci at MAC layer with dci_format=%d\n",dci_format); fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu_0_0 = &ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15; /* IDENTIFIER_DCI_FORMATS */ /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */ - nr_ue_process_dci_freq_dom_resource_assignment(&ulsch_config_pdu_0_0,NULL,n_RB_ULBWP,0,dci->freq_dom_resource_assignment_UL); + nr_ue_process_dci_freq_dom_resource_assignment(ulsch_config_pdu_0_0,NULL,n_RB_ULBWP,0,dci->freq_dom_resource_assignment_UL); /* TIME_DOM_RESOURCE_ASSIGNMENT */ - nr_ue_process_dci_time_dom_resource_assignment(&ulsch_config_pdu_0_0,NULL,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); + nr_ue_process_dci_time_dom_resource_assignment(ulsch_config_pdu_0_0,NULL,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); /* FREQ_HOPPING_FLAG */ if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.resource_allocation != 0) && (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.frequency_hopping !=0)) @@ -1377,9 +1383,9 @@ printf("\n>>> nr_ue_process_dci at MAC layer with dci_format=%d\n",dci_format); /* BANDWIDTH_PART_IND */ ulsch_config_pdu_0_1->bandwidth_part_ind = dci->bandwidth_part_ind; /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */ - nr_ue_process_dci_freq_dom_resource_assignment(&ulsch_config_pdu_0_1,NULL,n_RB_ULBWP,0,dci->freq_dom_resource_assignment_UL); + nr_ue_process_dci_freq_dom_resource_assignment(ulsch_config_pdu_0_1,NULL,n_RB_ULBWP,0,dci->freq_dom_resource_assignment_UL); /* TIME_DOM_RESOURCE_ASSIGNMENT */ - nr_ue_process_dci_time_dom_resource_assignment(&ulsch_config_pdu_0_1,NULL,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); + nr_ue_process_dci_time_dom_resource_assignment(ulsch_config_pdu_0_1,NULL,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); /* FREQ_HOPPING_FLAG */ if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.resource_allocation != 0) && (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.frequency_hopping !=0)) @@ -1769,8 +1775,7 @@ printf("\n>>> nr_ue_process_dci at MAC layer with dci_format=%d\n",dci_format); //for (int k=0;k<1000;k++) printf(">>> %d ",k); //mac->if_module->dl_indication(&mac->dl_info); //mac->if_module->dl_indication(&mac->dl_config_request); - mac->if_module->dl_indication(&mac->phy_config); - + mac->if_module->dl_indication(&mac->phy_config); break; diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index ef7d08d2fd..1ea888eeb9 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -33,6 +33,7 @@ #include "NR_IF_Module.h" #include "mac_proto.h" #include "assertions.h" +#include "LAYER2/NR_MAC_UE/mac_extern.h" #include @@ -134,7 +135,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info){ for(i=0; idci_ind->number_of_dcis; ++i){ printf(">>>NR_IF_Module i=%d, dl_info->dci_ind->number_of_dcis=%d\n",i,dl_info->dci_ind->number_of_dcis); fapi_nr_dci_pdu_rel15_t *dci = &dl_info->dci_ind->dci_list[i].dci; - + /* ret_mask |= (handle_dci( dl_info->module_id, dl_info->cc_id, @@ -142,7 +143,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info){ dci, (dl_info->dci_ind->dci_list+i)->rnti, (dl_info->dci_ind->dci_list+i)->dci_format)) << FAPI_NR_DCI_IND; - + */ /*switch((dl_info->dci_ind->dci_list+i)->dci_type){ case FAPI_NR_DCI_TYPE_0_0: @@ -211,7 +212,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info){ break; case FAPI_NR_RX_PDU_TYPE_DLSCH: // ret_mask |= (0) << FAPI_NR_RX_PDU_TYPE_DLSCH; - ret_mask |= (handle_dlsch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, &dl_info->dci_ind, + ret_mask |= (handle_dlsch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, dl_info->dci_ind, (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu, (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu_length)) << FAPI_NR_RX_PDU_TYPE_DLSCH; @@ -224,6 +225,9 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info){ } } + //clean up nr_downlink_indication_t *dl_info + dl_info->rx_ind = NULL; + dl_info->dci_ind = NULL; AssertFatal( nr_ue_if_module_inst[module_id] != NULL, "IF module is void!\n" ); nr_ue_if_module_inst[module_id]->scheduled_response(&mac->scheduled_response); @@ -256,3 +260,52 @@ int nr_ue_if_module_kill(uint32_t module_id) { } return 0; } + +int nr_ue_dcireq(nr_dcireq_t *dcireq) { + + fapi_nr_dl_config_request_t *dl_config=&dcireq->dl_config_req; + + // Type0 PDCCH search space + dl_config->number_pdus = 1; + dl_config->dl_config_list[0].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI; + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.rnti = 0xaaaa; // to be set + + uint64_t mask = 0x0; + uint16_t num_rbs=48; + uint16_t rb_offset=47; + uint16_t cell_id=0; + uint16_t num_symbols=2; + for(int i=0; i<(num_rbs/6); ++i){ // 38.331 Each bit corresponds a group of 6 RBs + mask = mask >> 1; + mask = mask | 0x100000000000; + } + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.frequency_domain_resource = mask; + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.rb_offset = rb_offset; // additional parameter other than coreset + + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.duration = num_symbols; + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.cce_reg_mapping_type =CCE_REG_MAPPING_TYPE_INTERLEAVED; + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.cce_reg_interleaved_reg_bundle_size = 6; // L 38.211 7.3.2.2 + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.cce_reg_interleaved_interleaver_size = 2; // R 38.211 7.3.2.2 + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.cce_reg_interleaved_shift_index = cell_id; + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.precoder_granularity = PRECODER_GRANULARITY_SAME_AS_REG_BUNDLE; + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.pdcch_dmrs_scrambling_id = cell_id; + + uint32_t number_of_search_space_per_slot=1; + uint32_t first_symbol_index=0; + uint32_t search_space_duration=1; // element of search space + uint32_t coreset_duration; // element of coreset + + coreset_duration = num_symbols * number_of_search_space_per_slot; + + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[0] = table_38213_10_1_1_c2[0]; + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[1] = table_38213_10_1_1_c2[1]; + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[2] = table_38213_10_1_1_c2[2]; // CCE aggregation level = 4 + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[3] = table_38213_10_1_1_c2[3]; // CCE aggregation level = 8 + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[4] = table_38213_10_1_1_c2[4]; // CCE aggregation level = 16 + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.duration = search_space_duration; + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.monitoring_symbols_within_slot = (0x3fff << first_symbol_index) & (0x3fff >> (14-coreset_duration-first_symbol_index)) & 0x3fff; + + dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.N_RB_BWP = 106; + + +} diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h index df30b9d599..0ecba9736d 100755 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h @@ -137,7 +137,7 @@ typedef struct { * -1: Failed to consume bytes. Abort the mission. * Non-negative return values indicate success, and ignored. */ -typedef int (nr_ue_scheduled_response_f)(nr_scheduled_response_t *scheduled_response); +typedef int8_t (nr_ue_scheduled_response_f)(nr_scheduled_response_t *scheduled_response); /* @@ -147,7 +147,7 @@ typedef int (nr_ue_scheduled_response_f)(nr_scheduled_response_t *scheduled_resp * -1: Failed to consume bytes. Abort the mission. * Non-negative return values indicate success, and ignored. */ -typedef int (nr_ue_phy_config_request_f)(nr_phy_config_t *phy_config); +typedef int8_t (nr_ue_phy_config_request_f)(nr_phy_config_t *phy_config); /* @@ -176,7 +176,7 @@ typedef struct nr_ue_if_module_s { nr_ue_phy_config_request_f *phy_config_request; nr_ue_dl_indication_f *dl_indication; nr_ue_ul_indication_f *ul_indication; - nr_ue_dcireq_f *dcireq; + //nr_ue_dcireq_f *dcireq; uint32_t cc_mask; uint32_t current_frame; uint32_t current_slot; diff --git a/targets/ARCH/ADRV9371_ZC706/SYRTEM_IQ_QuickStart.readme b/targets/ARCH/ADRV9371_ZC706/SYRTEM_IQ_QuickStart.readme index d7f6585a75..cd74fdb397 100755 --- a/targets/ARCH/ADRV9371_ZC706/SYRTEM_IQ_QuickStart.readme +++ b/targets/ARCH/ADRV9371_ZC706/SYRTEM_IQ_QuickStart.readme @@ -115,8 +115,16 @@ sudo cset shield --reset cd eur_oai_develop-nr/openairinterface5g/ source oaienv -sudo -E ./cmake_targets/build_oai -c --gNB -w ADRV9371_ZC706 -I -sudo -E ./cmake_targets/build_oai -c --gNB -w ADRV9371_ZC706 +sudo -E ./cmake_targets/build_oai -c --gNB -w ADRV9371_ZC706 -I --enable-cpu-affinity + +/* CPU available shall be mapped on CPU2 to get_nprocs() number with hyperthreading disabled */ +/* because : */ +/* - cset shield leave CPU0 for system */ +/* - CPU1 is reserved for HwRxTx thread for I/Q acquisition ! */ +/* Note: "/usr/local/etc/syriq/cpu-irq.sh" shall be changed if more than 8 cores are used */ +/* ie. "cset shield --force --kthread on -c 1-7" where "-c 1-7" reserves CPU1 to CPU7 for application (CPU0 is for system) */ + +sudo -E ./cmake_targets/build_oai -c --gNB -w ADRV9371_ZC706 --enable-cpu-affinity diff --git a/targets/COMMON/threads_t.h b/targets/COMMON/threads_t.h index 99fb0d8cf4..0671f40988 100644 --- a/targets/COMMON/threads_t.h +++ b/targets/COMMON/threads_t.h @@ -2,19 +2,20 @@ #define _THREADS_T_H_ typedef struct threads_s { - int iq; - int one; - int two; - int three; - int slot1_proc_one; - int slot1_proc_two; - int slot1_proc_three; - int dlsch_td_one; - int dlsch_td_two; - int dlsch_td_three; - int dlsch_td1_one; - int dlsch_td1_two; - int dlsch_td1_three; + int main; + int sync; + int one; + int two; + int three; + int slot1_proc_one; + int slot1_proc_two; + int slot1_proc_three; + //int dlsch_td_one; + //int dlsch_td_two; + //int dlsch_td_three; + //int dlsch_td1_one; + //int dlsch_td1_two; + //int dlsch_td1_three; } threads_t; #endif /* _THREADS_T_H_ */ diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 03a461454f..8dbd1d51c9 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -253,7 +253,7 @@ extern char uecap_xer[1024]; char uecap_xer_in=0; int oaisim_flag=0; -threads_t threads= {-1,-1,-1,-1,-1,-1,-1}; +threads_t threads= {-1,-1,-1,-1,-1,-1,-1,-1}; /* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed * this is very hackish - find a proper solution @@ -906,14 +906,16 @@ int main( int argc, char **argv ) char cpu_affinity[1024]; CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY + int j; if (get_nprocs() > 2) { - CPU_SET(0, &cpuset); + for (j = 2; 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"); } - LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); + LOG_I(HW, "Setting the affinity of main function to all CPUs, for device library to use CPU 0 only!\n"); } #endif diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 96ab799c3d..0870405fac 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -169,7 +169,8 @@ {"clock", CONFIG_HLP_CLK, 0, uptr:&clock_source, defintval:0, TYPE_UINT, 0}, \ {"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \ {"single-thread-enable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:0, TYPE_INT, 0}, \ -{"threadIQ", NULL, 0, iptr:&(threads.iq), defintval:1, TYPE_INT, 0}, \ +{"threadMain", NULL, 0, iptr:&(threads.main), defintval:1, TYPE_INT, 0}, \ +{"threadSync", NULL, 0, iptr:&(threads.sync), defintval:1, TYPE_INT, 0}, \ {"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:1, TYPE_INT, 0}, \ {"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:1, TYPE_INT, 0}, \ {"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:1, TYPE_INT, 0}, \ diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 965203f47e..a9a880dde7 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -456,8 +456,8 @@ static void *UE_thread_synch(void *arg) cpu_set_t cpuset; CPU_ZERO(&cpuset); - if ( threads.iq != -1 ) - CPU_SET(threads.iq, &cpuset); + if ( threads.sync != -1 ) + CPU_SET(threads.sync, &cpuset); // this thread priority must be lower that the main acquisition thread sprintf(threadname, "sync UE %d\n", UE->Mod_id); init_thread(100000, 500000, FIFO_PRIORITY-1, &cpuset, threadname); @@ -1435,8 +1435,8 @@ void *UE_thread(void *arg) { cpu_set_t cpuset; CPU_ZERO(&cpuset); - if ( threads.iq != -1 ) - CPU_SET(threads.iq, &cpuset); + if ( threads.main != -1 ) + CPU_SET(threads.main, &cpuset); init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, "UHD Threads"); diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 3d2995e5d1..617756e722 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -260,7 +260,7 @@ extern char uecap_xer[1024]; char uecap_xer_in=0; int oaisim_flag=0; -threads_t threads= {-1,-1,-1,-1,-1,-1,-1}; +threads_t threads = {-1,-1,-1,-1,-1,-1,-1}; /* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed * this is very hackish - find a proper solution @@ -1014,14 +1014,17 @@ printf("~~~~~~~~~~~~~~~~~~~~successfully get the parallel config[%d], worker con char cpu_affinity[1024]; CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY + int j; if (get_nprocs() > 2) { - CPU_SET(0, &cpuset); + for (j = 2; 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"); } - LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); + LOG_I(HW, "Setting the affinity of main function to all CPUs, for device library to use CPU 0 only!\n"); } #endif diff --git a/targets/RT/USER/nr-ru.c b/targets/RT/USER/nr-ru.c index 73d7c5dae1..af3916604e 100644 --- a/targets/RT/USER/nr-ru.c +++ b/targets/RT/USER/nr-ru.c @@ -1286,7 +1286,7 @@ static void* ru_thread_tx( void* param ) { gNB_L1_rxtx_proc_t *L1_proc; NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; char filename[40]; - int print_frame = 2; + int print_frame = 8; int i = 0; cpu_set_t cpuset; @@ -1402,8 +1402,8 @@ static void* ru_thread( void* param ) { int ret; int slot = fp->slots_per_frame-1; int frame =1023; - char filename[40]; - int print_frame = 2; + char filename[40],threadname[40]; + int print_frame = 8; int i = 0; // set default return value @@ -1411,7 +1411,8 @@ static void* ru_thread( void* param ) { // set default return value - thread_top_init("ru_thread",0,870000,1000000,1000000); + sprintf(threadname,"ru_thread %d",ru->idx); + thread_top_init(threadname,0,870000,1000000,1000000); LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,NB_functions[ru->function],NB_timing[ru->if_timing]); diff --git a/targets/RT/USER/nr-softmodem.c b/targets/RT/USER/nr-softmodem.c index 0c29c90f62..3bc9bf49d9 100644 --- a/targets/RT/USER/nr-softmodem.c +++ b/targets/RT/USER/nr-softmodem.c @@ -247,8 +247,6 @@ double cpuf; extern char uecap_xer[1024]; char uecap_xer_in=0; -threads_t threads= {-1,-1,-1,-1,-1,-1,-1}; - /* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed * this is very hackish - find a proper solution */ @@ -1034,14 +1032,19 @@ int main( int argc, char **argv ) char cpu_affinity[1024]; CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY + int j; if (get_nprocs() > 2) { - CPU_SET(0, &cpuset); + // CPU_SET(1, &cpuset); + for (j = 2; 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"); } - LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); + LOG_I(HW, "Setting the affinity of main function to all CPUs, for device library to use CPU 0 only!\n"); } #endif diff --git a/targets/RT/USER/nr-softmodem.h b/targets/RT/USER/nr-softmodem.h index 9dce5f34bd..5ee2880f3d 100644 --- a/targets/RT/USER/nr-softmodem.h +++ b/targets/RT/USER/nr-softmodem.h @@ -152,12 +152,6 @@ {"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \ {"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \ {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ -{"threadIQ", NULL, 0, iptr:&(threads.iq), defintval:1, TYPE_INT, 0}, \ -{"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:1, TYPE_INT, 0}, \ -{"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:1, TYPE_INT, 0}, \ -{"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:1, TYPE_INT, 0}, \ -{"threadSlot1ProcOne", NULL, 0, iptr:&(threads.slot1_proc_one), defintval:1, TYPE_INT, 0}, \ -{"threadSlot1ProcTwo", NULL, 0, iptr:&(threads.slot1_proc_two), defintval:1, TYPE_INT, 0}, \ {"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ {"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:DEFAULT_DLF, TYPE_UINT, 0}, \ {"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \ diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index dabb5e140a..1dfa3dbd4f 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -341,8 +341,8 @@ static void *UE_thread_synch(void *arg) { cpu_set_t cpuset; CPU_ZERO(&cpuset); - if ( threads.iq != -1 ) - CPU_SET(threads.iq, &cpuset); + if ( threads.sync != -1 ) + CPU_SET(threads.sync, &cpuset); // this thread priority must be lower that the main acquisition thread sprintf(threadname, "sync UE %d", UE->Mod_id); init_thread(100000, 500000, FIFO_PRIORITY-1, &cpuset, threadname); @@ -673,6 +673,8 @@ static void *UE_thread_rxn_txnp4(void *arg) { // pickTime(current); // updateTimes(proc->gotIQs, &t2, 10000, "Delay to wake up UE_Thread_Rx (case 2)"); + + // Process Rx data for one sub-frame if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_DOWNLINK_SLOT) { @@ -687,8 +689,12 @@ static void *UE_thread_rxn_txnp4(void *arg) { UE->dcireq.cc_id = 0; UE->dcireq.frame = proc->frame_rx; UE->dcireq.slot = proc->nr_tti_rx; - UE->if_inst->dcireq(&UE->dcireq); + nr_ue_dcireq(&UE->dcireq); //to be replaced with function pointer later + NR_UE_MAC_INST_t *UE_mac = get_mac_inst(0); + UE_mac->scheduled_response.dl_config = &UE->dcireq.dl_config_req; + nr_ue_scheduled_response(&UE_mac->scheduled_response); + #ifdef UE_SLOT_PARALLELISATION phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); #else @@ -707,68 +713,17 @@ static void *UE_thread_rxn_txnp4(void *arg) { // trigger L2 to run ue_scheduler thru IF module // [TODO] mapping right after NR initial sync - if(1) if(UE->if_inst != NULL && UE->if_inst->ul_indication != NULL){ UE->ul_indication.module_id = 0; UE->ul_indication.gNB_index = 0; UE->ul_indication.cc_id = 0; - UE->ul_indication.slot = 0; // to be fill - UE->ul_indication.frame = 0; // to be fill - // [TODO] mapping right after NR initial sync UE->ul_indication.frame = proc->frame_rx; UE->ul_indication.slot = proc->nr_tti_rx; UE->if_inst->ul_indication(&UE->ul_indication); } - - - -#ifdef NEW_MAC - ret = mac_xface->ue_scheduler(UE->Mod_id, - proc->frame_rx, - proc->subframe_rx, - proc->nr_tti_rx, - proc->frame_tx, - proc->subframe_tx, - proc->nr_tti_tx%(UE->frame_parms.ttis_per_subframe), -#ifndef NO_RAT_NR - slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx), -#else - subframe_select(&UE->frame_parms,proc->subframe_tx), -#endif - 0, - 0/*FIXME CC_id*/); -#endif - -/*#else - ret = mac_xface->ue_scheduler(UE->Mod_id, - proc->frame_rx, - proc->subframe_rx, - proc->frame_tx, - proc->subframe_tx, - subframe_select(&UE->frame_parms,proc->subframe_tx), - 0, */ -// 0/*FIXME CC_id*/); -//#endif - if ( ret != CONNECTION_OK) { - char *txt; - switch (ret) { - case CONNECTION_LOST: - txt="RRC Connection lost, returning to PRACH"; - break; - case PHY_RESYNCH: - txt="RRC Connection lost, trying to resynch"; - break; - case RESYNCH: - txt="return to PRACH and perform a contention-free access"; - break; - default: - txt="UNKNOWN RETURN CODE"; - }; - LOG_E( PHY, "[UE %"PRIu8"] Frame %"PRIu32", subframe %u %s\n", - UE->Mod_id, proc->frame_rx, proc->subframe_tx,txt ); - } - } + } + #if UE_TIMING_TRACE stop_meas(&UE->generic_stat); #endif @@ -842,15 +797,15 @@ void *UE_thread(void *arg) { cpu_set_t cpuset; CPU_ZERO(&cpuset); - if ( threads.iq != -1 ) - CPU_SET(threads.iq, &cpuset); - init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, - "UHD Threads"); + if ( threads.main != -1 ) + CPU_SET(threads.main, &cpuset); + sprintf(threadname, "Main UE %d", UE->Mod_id); + init_thread(100000, 500000, FIFO_PRIORITY, &cpuset,threadname); + if ((oaisim_flag == 0) && (UE->mode !=loop_through_memory)) AssertFatal(0== openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]), ""); UE->rfdevice.host_type = RAU_HOST; - sprintf(threadname, "Main UE %d", UE->Mod_id); - pthread_setname_np(pthread_self(), threadname); + init_UE_threads(UE); #ifdef NAS_UE @@ -1132,23 +1087,41 @@ void *UE_thread(void *arg) { proc->nr_tti_tx %= NR_NUMBER_OF_SUBFRAMES_PER_FRAME; } proc->subframe_tx=proc->nr_tti_tx; - - printf("Processing subframe %d\n",proc->subframe_rx); + + if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_DOWNLINK_SLOT) { + + //clean previous FAPI MESSAGE + UE->rx_ind.number_pdus = 0; + UE->dci_ind.number_of_dcis = 0; + //clean previous FAPI MESSAGE + + // call L2 for DL_CONFIG (DCI) + UE->dcireq.module_id = UE->Mod_id; + UE->dcireq.gNB_index = 0; + UE->dcireq.cc_id = 0; + UE->dcireq.frame = proc->frame_rx; + UE->dcireq.slot = proc->nr_tti_rx; + nr_ue_dcireq(&UE->dcireq); //to be replaced with function pointer later + + NR_UE_MAC_INST_t *UE_mac = get_mac_inst(0); + UE_mac->scheduled_response.dl_config = &UE->dcireq.dl_config_req; + nr_ue_scheduled_response(&UE_mac->scheduled_response); + + + printf("Processing subframe %d\n",proc->subframe_rx); + phy_procedures_nrUE_RX( UE, proc, 0, 1, UE->mode); + } if(UE->if_inst != NULL && UE->if_inst->ul_indication != NULL){ UE->ul_indication.module_id = 0; UE->ul_indication.gNB_index = 0; UE->ul_indication.cc_id = 0; - UE->ul_indication.slot = 0; // to be fill - UE->ul_indication.frame = 0; // to be fill - // [TODO] mapping right after NR initial sync UE->ul_indication.frame = proc->frame_rx; UE->ul_indication.slot = proc->nr_tti_rx; UE->if_inst->ul_indication(&UE->ul_indication); } - phy_procedures_nrUE_RX( UE, proc, 0, 1, UE->mode); getchar(); } // else loop_through_memory } // start_rx_stream==1 diff --git a/targets/RT/USER/nr-uesoftmodem.c b/targets/RT/USER/nr-uesoftmodem.c index 0e408533ac..81f46d31b3 100644 --- a/targets/RT/USER/nr-uesoftmodem.c +++ b/targets/RT/USER/nr-uesoftmodem.c @@ -268,7 +268,8 @@ char uecap_xer[1024],uecap_xer_in=0; int oaisim_flag=0; int emulate_rf = 0; -threads_t threads= {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; +threads_t threads = {-1,-1,-1,-1,-1,-1,-1,-1}; +int threads_offset = 0; char* usrp_args=NULL; char* usrp_clksrc=NULL; @@ -1027,8 +1028,25 @@ int main( int argc, char **argv ) { //dump_frame_parms(frame_parms[0]); init_openair0(); - + // default threads.main = 2 + // if there are enough processors, all others on subsequent CPUs + if (threads_offset>0) { + if (threads_offset+8<=get_nprocs()) { + if (threads.main<0) threads.main=threads_offset+1; + if (threads.sync<0) threads.sync=threads_offset+2; + if (threads.one<0) threads.one=threads_offset+3; + if (threads.two<0) threads.two=threads_offset+4; + if (threads.three<0) threads.three=threads_offset+5; + if (threads.slot1_proc_one<0) threads.slot1_proc_one=threads_offset+6; + if (threads.slot1_proc_two<0) threads.slot1_proc_two=threads_offset+7; + if (threads.slot1_proc_three<0) threads.slot1_proc_three=threads_offset+8; + } + else { + LOG_E(HW,"Not enough CPUs available (nprocs (=%d) >= threadmain (=%d) + 10)\n",get_nprocs(),threads_offset); + exit_fun("Error setting thread affinity\n"); + } + } #ifndef DEADLINE_SCHEDULER @@ -1039,14 +1057,17 @@ int main( int argc, char **argv ) { char cpu_affinity[1024]; CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY - if (get_nprocs() > 2) { - CPU_SET(0, &cpuset); + int j; + if (get_nprocs()>=2) { + for (j = 2; 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"); } - LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); + LOG_I(HW, "Setting the affinity of main function to all CPUs, for device library to use CPU 0 only!\n"); } #endif diff --git a/targets/RT/USER/nr-uesoftmodem.h b/targets/RT/USER/nr-uesoftmodem.h index 99fb64f175..816e753086 100644 --- a/targets/RT/USER/nr-uesoftmodem.h +++ b/targets/RT/USER/nr-uesoftmodem.h @@ -157,13 +157,16 @@ {"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \ {"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \ {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ -{"threadIQ", NULL, 0, iptr:&(threads.iq), defintval:1, TYPE_INT, 0}, \ -{"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:1, TYPE_INT, 0}, \ -{"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:1, TYPE_INT, 0}, \ -{"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:1, TYPE_INT, 0}, \ -{"threadSlot1ProcOne", NULL, 0, iptr:&(threads.slot1_proc_one), defintval:1, TYPE_INT, 0}, \ -{"threadSlot1ProcTwo", NULL, 0, iptr:&(threads.slot1_proc_two), defintval:1, TYPE_INT, 0}, \ -{"nr_dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ +{"threadoffset", NULL, 0, iptr:&(threads_offset), defintval:0, TYPE_INT, 0}, \ +{"threadMain", NULL, 0, iptr:&(threads.main), defintval:-1, TYPE_INT, 0}, \ +{"threadSync", NULL, 0, iptr:&(threads.sync), defintval:-1, TYPE_INT, 0}, \ +{"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:-1, TYPE_INT, 0}, \ +{"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:-1, TYPE_INT, 0}, \ +{"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:-1, TYPE_INT, 0}, \ +{"threadSlot1ProcOne", NULL, 0, iptr:&(threads.slot1_proc_one), defintval:-1, TYPE_INT, 0}, \ +{"threadSlot1ProcTwo", NULL, 0, iptr:&(threads.slot1_proc_two), defintval:-1, TYPE_INT, 0}, \ +{"threadSlot1ProcThree", NULL, 0, iptr:&(threads.slot1_proc_three), defintval:-1, TYPE_INT, 0}, \ +{"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ {"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ {"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:2680000000, TYPE_UINT, 0}, \ {"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \ diff --git a/targets/RT/USER/rt_wrapper.c b/targets/RT/USER/rt_wrapper.c index 443d183068..e4dc54f78f 100644 --- a/targets/RT/USER/rt_wrapper.c +++ b/targets/RT/USER/rt_wrapper.c @@ -294,20 +294,20 @@ void thread_top_init(char *thread_name, char cpu_affinity[1024]; cpu_set_t cpuset; - /* Set affinity mask to include CPUs 1 to MAX_CPUS */ + /* Set affinity mask to include CPUs 2 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 */ + /* Enable CPU Affinity only if number of CPUs > 2 */ CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY - if (get_nprocs() > 2) + if (affinity == 0) { + LOG_W(HW,"thread_top_init() called with affinity==0, but overruled by #ifdef CPU_AFFINITY\n"); + } + else if (get_nprocs() > 2) { - if (affinity == 0) - CPU_SET(0,&cpuset); - else - for (j = 1; j < get_nprocs(); j++) - CPU_SET(j, &cpuset); + for (j = 2; j < get_nprocs(); j++) + CPU_SET(j, &cpuset); s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); if (s != 0) { @@ -315,21 +315,29 @@ void thread_top_init(char *thread_name, exit_fun("Error setting processor affinity"); } } +#else //CPU_AFFINITY + if (affinity) { + LOG_W(HW,"thread_top_init() called with affinity>0, but overruled by #ifndef CPU_AFFINITY.\n"); + } #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) { + if (s != 0) + { perror( "pthread_getaffinity_np"); exit_fun("Error getting processor affinity "); } memset(cpu_affinity,0,sizeof(cpu_affinity)); for (j = 0; j < 1024; j++) - if (CPU_ISSET(j, &cpuset)) { + { + 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);