From bc295b3ba59004c81e396e9163eca16ec772fef1 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Fri, 1 Sep 2023 10:55:05 +0100 Subject: [PATCH] Check ULSCH transport block CRC --- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 15 +++++++++++++++ openair1/SCHED_NR/phy_procedures_nr_gNB.c | 16 ++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index ab63282c9b..ad7f83d6db 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -463,7 +463,22 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING, 0); + bool crc_valid = false; if (harq_process->processedSegments == harq_process->C) { + // When the number of code blocks is 1 (C = 1) and ulsch_harq->processedSegments = 1, we can assume a good TB because of the + // CRC check made by the LDPC for early termination, so, no need to perform CRC check twice for a single code block + crc_valid = true; + if (harq_process->C > 1) { + // Check ULSCH transport block CRC + crc_type = CRC16; + if (A > 3824) { + crc_type = CRC24_A; + } + crc_valid = check_crc(harq_process->b, harq_process->B, crc_type); + } + } + + if (crc_valid) { LOG_D(PHY, "[gNB %d] ULSCH: Setting ACK for slot %d TBS %d\n", phy_vars_gNB->Mod_id, ulsch->slot, harq_process->TBS); ulsch->active = false; harq_process->round = 0; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 5ce9b7e39b..a8137e70f2 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -261,8 +261,20 @@ static void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) //int dumpsig=0; // if all segments are done - if (rdata->nbSegments == ulsch_harq->processedSegments) { - if (!check_abort(&ulsch_harq->abort_decode) && !gNB->pusch_vars[rdata->ulsch_id].DTX) { + if (ulsch_harq->processedSegments == ulsch_harq->C) { + // When the number of code blocks is 1 (C = 1) and ulsch_harq->processedSegments = 1, we can assume a good TB because of the + // CRC check made by the LDPC for early termination, so, no need to perform CRC check twice for a single code block + bool crc_valid = true; + if (ulsch_harq->C > 1) { + // Check ULSCH transport block CRC + int crc_type = CRC16; + if (rdata->A > 3824) { + crc_type = CRC24_A; + } + crc_valid = check_crc(ulsch_harq->b, ulsch_harq->B, crc_type); + } + + if (crc_valid && !check_abort(&ulsch_harq->abort_decode) && !gNB->pusch_vars[rdata->ulsch_id].DTX) { LOG_D(PHY, "[gNB %d] ULSCH: Setting ACK for SFN/SF %d.%d (rnti %x, pid %d, ndi %d, status %d, round %d, TBS %d, Max interation " "(all seg) %d)\n",