From e45a051c80d76eeec721ac007bc67a21a2f0b479 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Wed, 1 Feb 2023 10:17:59 -0500 Subject: [PATCH] Perform CRC check for whole TB --- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 37 ++++++++++--------- openair1/PHY/defs_nr_UE.h | 1 + 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index bf18d79189..470164817b 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -51,15 +51,8 @@ #define OAI_UL_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX = 68*384 //#define OAI_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX -static uint64_t nb_total_decod =0; -static uint64_t nb_error_decod =0; - static extended_kpi_ue kpiStructure = {0}; -notifiedFIFO_t freeBlocks_dl; -notifiedFIFO_elt_t *msgToPush_dl; -int nbDlProcessing =0; - extended_kpi_ue* getKPIUE(void) { return &kpiStructure; } @@ -77,7 +70,7 @@ void nr_dlsch_unscrambling(int16_t *llr, uint32_t size, uint8_t q, uint32_t Nid, nr_codeword_unscrambling(llr, size, q, Nid, n_RNTI); } -bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *req, bool last, notifiedFIFO_t *nf_p, int b_size, uint8_t b[b_size]) { +bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *req, bool last, notifiedFIFO_t *nf_p, int b_size, uint8_t b[b_size], int *num_seg_ok, UE_nr_rxtx_proc_t *proc) { ldpcDecode_ue_t *rdata = (ldpcDecode_ue_t*) NotifiedFifoData(req); NR_DL_UE_HARQ_t *harq_process = rdata->harq_process; NR_UE_DLSCH_t *dlsch = (NR_UE_DLSCH_t *) rdata->dlsch; @@ -94,6 +87,7 @@ bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *req, bool harq_process->c[r], rdata->Kr_bytes - (harq_process->F>>3) -((harq_process->C>1)?3:0)); + (*num_seg_ok)++; } else { if ( !last ) { int nb=abortTpoolJob(&get_nrUE_params()->Tpool, req->key); @@ -111,7 +105,20 @@ bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, notifiedFIFO_elt_t *req, bool kpiStructure.dl_mcs = dlsch->dlsch_config.mcs; kpiStructure.nofRBs = dlsch->dlsch_config.number_rbs; - if (decodeSuccess) { + if (*num_seg_ok == harq_process->C) { + if (harq_process->C > 1) { + /* check global CRC */ + int A = dlsch->dlsch_config.TBS; + int crc_length = A > 3824 ? 3 : 2; + int crc_type = A > 3824 ? CRC24_A : CRC16; + if (!check_crc(b, A + crc_length*8, 0 /* F - unused */, crc_type)) { + harq_process->ack = 0; + dlsch->last_iteration_cnt = dlsch->max_ldpc_iterations + 1; + LOG_E(PHY, " Frame %d.%d LDPC global CRC fails, but individual LDPC CRC succeeded. %d segs\n", proc->frame_rx, proc->nr_slot_rx, harq_process->C); + LOG_D(PHY, "DLSCH received nok \n"); + return true; //stop + } + } //LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for nr_slot_rx %d TBS %d mcs %d nb_rb %d harq_process->round %d\n", // phy_vars_ue->Mod_id,nr_slot_rx,harq_process->TBS,harq_process->mcs,harq_process->nb_rb, harq_process->round); harq_process->status = SCH_IDLE; @@ -277,7 +284,7 @@ void nr_processDLSegment(void* arg) { if (no_iteration_ldpc > dlsch->max_ldpc_iterations) no_iteration_ldpc = dlsch->max_ldpc_iterations; } else { - LOG_D(PHY,"CRC NOT OK\n"); + LOG_I(PHY,"%d.%d CRC NOT OK\n",rdata->proc->frame_rx,rdata->proc->nr_slot_rx); no_iteration_ldpc = dlsch->max_ldpc_iterations + 1; } @@ -287,12 +294,6 @@ void nr_processDLSegment(void* arg) { rdata->decodeIterations = no_iteration_ldpc; - nb_total_decod++; - - if (no_iteration_ldpc > dlsch->max_ldpc_iterations) { - nb_error_decod++; - } - for (int m=0; m < Kr>>3; m ++) { harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; } @@ -478,6 +479,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, rdata->offset = offset; rdata->dlsch = dlsch; rdata->dlsch_id = 0; + rdata->proc = proc; reset_meas(&rdata->ts_deinterleave); reset_meas(&rdata->ts_rate_unmatch); reset_meas(&rdata->ts_ldpc_decode); @@ -488,6 +490,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0)); ////////////////////////////////////////////////////////////////////////////////////////// } + int num_seg_ok = 0; for (r=0; rTpool); if (req == NULL) @@ -495,7 +498,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, bool last = false; if (r == nbDecode - 1) last = true; - bool stop = nr_ue_postDecode(phy_vars_ue, req, last, &nf, b_size, b); + bool stop = nr_ue_postDecode(phy_vars_ue, req, last, &nf, b_size, b, &num_seg_ok, proc); delNotifiedFIFO_elt(req); if (stop) break; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 9301f3fb9d..2276def8cd 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -709,6 +709,7 @@ typedef struct LDPCDecode_ue_s { time_stats_t ts_deinterleave; time_stats_t ts_rate_unmatch; time_stats_t ts_ldpc_decode; + UE_nr_rxtx_proc_t *proc; } ldpcDecode_ue_t; #include "SIMULATION/ETH_TRANSPORT/defs.h"