From bd2a27f6cca612d449bb6d8cde79f618fc7c44a4 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 24 Sep 2021 08:36:59 +0200 Subject: [PATCH] some more error checks + data collection --- .../nrLDPC_decoder/nrLDPC_decoder_offload.c | 20 ++++++++++-- openair1/PHY/INIT/nr_init.c | 4 ++- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 26 ++++++++++------ openair1/SIMULATION/NR_PHY/ulsim.c | 31 +++++++++++++------ 4 files changed, 59 insertions(+), 22 deletions(-) diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c index 822bf01f86..aee8090ca6 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c @@ -1161,17 +1161,27 @@ pmd_lcore_ldpc_dec(void *arg) deq += rte_bbdev_dequeue_ldpc_dec_ops(tp->dev_id, queue_id, &ops_deq[deq], enq - deq); + //printf("enq %d, deq %d\n",enq,deq); + } /* dequeue the remaining */ + int trials=0; while (deq < enq) { deq += rte_bbdev_dequeue_ldpc_dec_ops(tp->dev_id, queue_id, &ops_deq[deq], enq - deq); + usleep(10); + trials++; + if (trials>=100) { + printf("aborting decoding after 100 dequeue tries\n"); + break; + } } // total_time += rte_rdtsc_precise() - start_time; } + if (deq==enq) { tp->iter_count = 0; /* get the max of iter_count for all dequeued ops */ for (i = 0; i < num_ops; ++i) { @@ -1182,6 +1192,10 @@ pmd_lcore_ldpc_dec(void *arg) ret = retrieve_ldpc_dec_op(ops_deq, num_ops, ref_op, tp->op_params->vector_mask, p_out); TEST_ASSERT_SUCCESS(ret, "Validation failed!"); + } + else { + ret = TEST_FAILED; + } rte_bbdev_dec_op_free_bulk(ops_enq, num_ops); @@ -1193,7 +1207,7 @@ pmd_lcore_ldpc_dec(void *arg) 1000000.0) / ((double)total_time / (double)rte_get_tsc_hz()); */ - return TEST_SUCCESS; + return ret; } @@ -1513,14 +1527,14 @@ int32_t nrLDPC_decod_offload(t_nrLDPC_dec_params* p_decParams, uint8_t C, uint8_ info.drv.min_alignment, socket_id); if (f_ret != TEST_SUCCESS) { - printf("Couldn't init queue buffers"); + printf("Couldn't init queue buffers\n"); return(-1); } } ret = start_pmd_dec(ad, op_params, p_offloadParams, p_out); if (ret<0) { - printf("Couldn't start pmd dec"); + printf("Couldn't start pmd dec\n"); return(-1); } break; diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 8275037082..e875b7ca79 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -109,7 +109,9 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, init_pucch2_luts(); load_nrLDPClib(NULL); - load_nrLDPClib_offload(); + + if (gNB->ldpc_offload_flag) + load_nrLDPClib_offload(); // PBCH DMRS gold sequences generation nr_init_pbch_dmrs(gNB); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index b5d089ad2d..9384039b55 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -609,24 +609,31 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, Qm, (int8_t*)&pl_ol128[0], llrProcBuf, 1); - - for (int m=0; m < Kr>>3; m ++) { - harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; - } - - if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) { + + if (ret<0) { + no_iteration_ldpc = ulsch->max_ldpc_iterations + 1; + } + else { + + for (int m=0; m < Kr>>3; m ++) { + harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; + } + + if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) { #ifdef PRINT_CRC_CHECK LOG_I(PHY, "Segment %d CRC OK\n",r); #endif - no_iteration_ldpc = 2; - } else { + no_iteration_ldpc = 2; + } else { #ifdef PRINT_CRC_CHECK LOG_I(PHY, "CRC NOK\n"); #endif - no_iteration_ldpc = ulsch->max_ldpc_iterations + 1; + no_iteration_ldpc = ulsch->max_ldpc_iterations + 1; + } } r_offset += E; + /*for (int k=0;k<8;k++) { printf("output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); @@ -646,6 +653,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, LOG_I(PHY,"uplink segment error %d/%d\n",r,harq_process->C); LOG_D(PHY, "ULSCH %d in error\n",ULSCH_id); harq_process->processedSegments=harq_process->C; + r=harq_process->C; } } if (harq_process->processedSegments==harq_process->C){ diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 89b2107e6b..af76fd7086 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -312,6 +312,7 @@ int main(int argc, char **argv) uint8_t snrRun; int prb_inter = 0; int ldpc_offload_flag = 0; + uint8_t max_rounds = 4; int enable_ptrs = 0; int modify_dmrs = 0; @@ -345,7 +346,7 @@ int main(int argc, char **argv) /* initialize the sin-cos table */ InitSinLUT(); - while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:ikl:m:n:o:p:r:s:u:w:y:z:F:G:H:M:N:PR:S:T:U:L:Z")) != -1) { + while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:ikl:m:n:o:p:q:r:s:u:w:y:z:F:G:H:M:N:PR:S:T:U:L:Z")) != -1) { printf("handling optarg %c\n",c); switch (c) { @@ -465,6 +466,10 @@ int main(int argc, char **argv) case 'p': extended_prefix_flag = 1; break; + + case 'q': + max_rounds = atoi(optarg); + break; case 'r': nb_rb = atoi(optarg); @@ -756,7 +761,11 @@ int main(int argc, char **argv) nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; cfg->carrier_config.num_tx_ant.value = n_tx; cfg->carrier_config.num_rx_ant.value = n_rx; + // nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,0,0x01); + + gNB->ldpc_offload_flag = ldpc_offload_flag; + phy_init_nr_gNB(gNB,0,1); N_RB_DL = gNB->frame_parms.N_RB_DL; @@ -810,7 +819,6 @@ int main(int argc, char **argv) unsigned char harq_pid = 0; - gNB->ldpc_offload_flag = ldpc_offload_flag; NR_gNB_ULSCH_t *ulsch_gNB = gNB->ulsch[UE_id][0]; //nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &ulsch_gNB->harq_processes[harq_pid]->ulsch_pdu; nfapi_nr_ul_tti_request_t *UL_tti_req = malloc(sizeof(*UL_tti_req)); @@ -845,7 +853,6 @@ int main(int argc, char **argv) uint16_t n_rb1 = 75; uint16_t pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; // | PUSCH_PDU_BITMAP_PUSCH_PTRS; - uint8_t max_rounds = 4; uint8_t crc_status = 0; unsigned char mod_order = nr_get_Qm_ul(Imcs, mcs_table); @@ -1014,12 +1021,14 @@ int main(int argc, char **argv) double blerStats[4][100]; double berStats[4][100]; double snrStats[100]; + double ldpcDecStats[100]; memset(errors_scrambling, 0, sizeof(uint32_t)*4*100); memset(n_errors, 0, sizeof(int)*4*100); memset(round_trials, 0, sizeof(int)*4*100); memset(blerStats, 0, sizeof(double)*4*100); memset(berStats, 0, sizeof(double)*4*100); memset(snrStats, 0, sizeof(double)*100); + memset(ldpcDecStats, 0, sizeof(double)*100); for (SNR = snr0; SNR < snr1; SNR += snr_step) { varArray_t *table_rx=initVarArray(1000,sizeof(double)); int error_flag = 0; @@ -1421,16 +1430,16 @@ int main(int argc, char **argv) errors_decoding++; } } - if (n_trials == 1) { + /*if (n_trials == 1) { for (int r=0;rharq_processes[harq_pid]->C;r++) for (int i=0;iharq_processes[harq_pid]->K>>3;i++) { - if ((ulsch_ue[0]->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]) != 0) printf("************"); - /*printf("r %d: in[%d] %x, out[%d] %x (%x)\n",r, + if ((ulsch_ue[0]->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]) != 0) + printf("r %d: in[%d] %x, out[%d] %x (%x)\n",r, i,ulsch_ue[0]->harq_processes[harq_pid]->c[r][i], i,ulsch_gNB->harq_processes[harq_pid]->c[r][i], - ulsch_ue[0]->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]);*/ + ulsch_ue[0]->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]); } - } + }*/ if (errors_decoding > 0 && error_flag == 0) { n_false_positive++; if (n_trials==1) @@ -1496,6 +1505,8 @@ int main(int argc, char **argv) printf("\n"); } + ldpcDecStats[snrRun] = gNB->ulsch_decoding_stats.trials?inMicroS(gNB->ulsch_decoding_stats.diff/gNB->ulsch_decoding_stats.trials):0; + if(n_trials==1) break; @@ -1540,9 +1551,11 @@ int main(int argc, char **argv) LOG_MM("ulsimStats.m","BER_round3",berStats[3],snrRun,1,7); LOG_MM("ulsimStats.m","EffRate",effRate,snrRun,1,7); LOG_MM("ulsimStats.m","EffTP",effTP,snrRun,1,7); + LOG_MM("ulsimStats.m","LDPC_dec_time",ldpcDecStats,snrRun,1,7); free(test_input_bit); free(estimated_output_bit); - free_nrLDPClib_offload(); + if (gNB->ldpc_offload_flag) + free_nrLDPClib_offload(); if (output_fd) fclose(output_fd);