diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index cc566d6e1c..243e3f9a23 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -99,73 +99,58 @@ static bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, LOG_D(PHY, "DLSCH %d in error\n", rdata->dlsch_id); } - // if all segments are done - if (last) { - kpiStructure.nb_total++; - kpiStructure.blockSize = dlsch->dlsch_config.TBS; - kpiStructure.dl_mcs = dlsch->dlsch_config.mcs; - kpiStructure.nofRBs = dlsch->dlsch_config.number_rbs; + if (!last) + return false; // continue decoding - if (*num_seg_ok == harq_process->C) { - if (harq_process->C > 1) { - int A = dlsch->dlsch_config.TBS; - /* check global CRC */ - // we have regrouped the transport block, so it is "1" segment - if (!check_crc(b, lenWithCrc(1, A), crcType(1, A))) { - 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 - } - const int sz=A / 8; - if (b[sz] == 0 && b[sz + 1] == 0) { // We search only a reccuring OAI error that propagates all 0 packets with a 0 CRC, so we - // do the check only if the 2 first bytes of the CRC are 0 (it can be CRC16 or CRC24) - int i = 0; - while (b[i] == 0 && i < sz) - i++; - if (i == sz) { - LOG_E(PHY, - "received all 0 pdu, consider it false reception, even if the TS 38.212 7.2.1 says only we should attach the " - "corresponding CRC, and nothing prevents to have a all 0 packet\n"); - dlsch->last_iteration_cnt = dlsch->max_ldpc_iterations + 1; - 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; - harq_process->ack = 1; + // all segments are done + kpiStructure.nb_total++; + kpiStructure.blockSize = dlsch->dlsch_config.TBS; + kpiStructure.dl_mcs = dlsch->dlsch_config.mcs; + kpiStructure.nofRBs = dlsch->dlsch_config.number_rbs; - //LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d)\n", - // phy_vars_ue->Mod_id, frame, subframe, harq_pid, harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs); + harq_process->decodeResult = *num_seg_ok == harq_process->C; - //if(is_crnti) { - // LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for nr_slot_rx %d (pid %d, round %d, TBS %d)\n",phy_vars_ue->Mod_id,nr_slot_rx,harq_pid,harq_process->round,harq_process->TBS); - //} - dlsch->last_iteration_cnt = rdata->decodeIterations; - LOG_D(PHY, "DLSCH received ok \n"); - } else { - kpiStructure.nb_nack++; - //LOG_D(PHY,"[UE %d] DLSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n", - // phy_vars_ue->Mod_id, frame, nr_slot_rx, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs,Kr,r,harq_process->round); - harq_process->ack = 0; - - //if(is_crnti) { - // LOG_D(PHY,"[UE %d] DLSCH: Setting NACK for nr_slot_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n", - // phy_vars_ue->Mod_id,nr_slot_rx,harq_pid,harq_process->status,harq_process->round,dlsch->Mdlharq,harq_process->TBS); - //} - dlsch->last_iteration_cnt = dlsch->max_ldpc_iterations + 1; - LOG_D(PHY, "DLSCH received nok \n"); + if (harq_process->decodeResult && harq_process->C > 1) { + /* check global CRC */ + int A = dlsch->dlsch_config.TBS; + // we have regrouped the transport block + if (!check_crc(b, lenWithCrc(1, A), crcType(1, A))) { + 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); + harq_process->decodeResult = false; } - return true; //stop } - else { - return false; //not last one + + if (harq_process->decodeResult) { + // We search only a reccuring OAI error that propagates all 0 packets with a 0 CRC, so we + const int sz = dlsch->dlsch_config.TBS / 8; + if (b[sz] == 0 && b[sz + 1] == 0) { + // do the check only if the 2 first bytes of the CRC are 0 (it can be CRC16 or CRC24) + int i = 0; + while (b[i] == 0 && i < sz) + i++; + if (i == sz) { + LOG_E(PHY, + "received all 0 pdu, consider it false reception, even if the TS 38.212 7.2.1 says only we should attach the " + "corresponding CRC, and nothing prevents to have a all 0 packet\n"); + harq_process->decodeResult = false; + } + } } + + if (harq_process->decodeResult) { + LOG_D(PHY, "DLSCH received ok \n"); + harq_process->status = SCH_IDLE; + dlsch->last_iteration_cnt = rdata->decodeIterations; + } else { + LOG_D(PHY, "DLSCH received nok \n"); + kpiStructure.nb_nack++; + dlsch->last_iteration_cnt = dlsch->max_ldpc_iterations + 1; + } + return true; // end TB decoding } static void nr_processDLSegment(void *arg) @@ -174,13 +159,9 @@ static void nr_processDLSegment(void *arg) NR_UE_DLSCH_t *dlsch = rdata->dlsch; NR_DL_UE_HARQ_t *harq_process= rdata->harq_process; t_nrLDPC_dec_params *p_decoderParms = &rdata->decoderParms; - int Kr; - int K_bits_F; int r = rdata->segment_r; - int A = rdata->A; int E = rdata->E; int Qm = rdata->Qm; - //int rv_index = rdata->rv_index; int r_offset = rdata->r_offset; uint8_t kc = rdata->Kc; uint32_t Tbslbrm = rdata->Tbslbrm; @@ -189,8 +170,8 @@ static void nr_processDLSegment(void *arg) int16_t z[68 * 384 + 16] __attribute__((aligned(16))); int8_t l [68*384 + 16] __attribute__ ((aligned(16))); - Kr = harq_process->K; - K_bits_F = Kr-harq_process->F; + const int Kr = harq_process->K; + const int K_bits_F = Kr - harq_process->F; t_nrLDPC_time_stats procTime = {0}; @@ -265,6 +246,7 @@ static void nr_processDLSegment(void *arg) } //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_LDPC, VCD_FUNCTION_IN); + uint32_t A = dlsch->dlsch_config.TBS; p_decoderParms->E = lenWithCrc(harq_process->C, A); p_decoderParms->crc_type = crcType(harq_process->C, A); rdata->decodeIterations = @@ -331,26 +313,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, return(dlsch->max_ldpc_iterations + 1); } - /*if (nr_slot_rx> (frame_parms->slots_per_frame-1)) { - printf("dlsch_decoding.c: Illegal slot index %d\n",nr_slot_rx); - return(dlsch->max_ldpc_iterations + 1); - }*/ - /*if (harq_process->harq_ack.ack != 2) { - LOG_D(PHY, "[UE %d] DLSCH @ SF%d : ACK bit is %d instead of DTX even before PDSCH is decoded!\n", - phy_vars_ue->Mod_id, nr_slot_rx, harq_process->harq_ack.ack); - }*/ - // nb_rb = dlsch->nb_rb; - /* - if (nb_rb > frame_parms->N_RB_DL) { - printf("dlsch_decoding.c: Illegal nb_rb %d\n",nb_rb); - return(max_ldpc_iterations + 1); - }*/ - /*harq_pid = dlsch->current_harq_pid[proc->thread_id]; - if (harq_pid >= 8) { - printf("dlsch_decoding.c: Illegal harq_pid %d\n",harq_pid); - return(max_ldpc_iterations + 1); - } - */ nb_rb = dlsch->dlsch_config.number_rbs; uint32_t A = dlsch->dlsch_config.TBS; ret = dlsch->max_ldpc_iterations + 1; @@ -359,8 +321,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, // target_code_rate is in 0.1 units float Coderate = (float) dlsch->dlsch_config.targetCodeRate / 10240.0f; - LOG_D(PHY,"%d.%d DLSCH Decoding, harq_pid %d TBS %d (%d) G %d nb_re_dmrs %d length dmrs %d mcs %d Nl %d nb_symb_sch %d nb_rb %d Qm %d Coderate %f\n", - frame,nr_slot_rx,harq_pid,A,A/8,G, nb_re_dmrs, dmrs_length, dlsch->dlsch_config.mcs, dlsch->Nl, nb_symb_sch, nb_rb, dlsch->dlsch_config.qamModOrder, Coderate); decParams.BG = dlsch->dlsch_config.ldpcBaseGraph; unsigned int kc = decParams.BG == 2 ? 52 : 68; @@ -426,11 +386,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, rdata->decoderParms = decParams; rdata->dlsch_llr = dlsch_llr; rdata->Kc = kc; - rdata->harq_pid = harq_pid; rdata->segment_r = r; - rdata->nbSegments = harq_process->C; rdata->E = E; - rdata->A = A; rdata->Qm = dlsch->dlsch_config.qamModOrder; rdata->r_offset = r_offset; rdata->Kr_bytes = Kr_bytes; @@ -438,8 +395,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, rdata->Tbslbrm = dlsch->dlsch_config.tbslbrm; rdata->offset = offset; rdata->dlsch = dlsch; - rdata->dlsch_id = 0; - rdata->proc = *proc; + rdata->dlsch_id = harq_pid; reset_meas(&rdata->ts_deinterleave); reset_meas(&rdata->ts_rate_unmatch); reset_meas(&rdata->ts_ldpc_decode); @@ -459,7 +415,26 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, delNotifiedFIFO_elt(req); nbDecode--; } - + LOG_D(PHY, + "%d.%d DLSCH Decoded, harq_pid %d, round %d, result: %d TBS %d (%d) G %d nb_re_dmrs %d length dmrs %d mcs %d Nl %d " + "nb_symb_sch %d " + "nb_rb %d Qm %d Coderate %f\n", + frame, + nr_slot_rx, + harq_pid, + harq_process->DLround, + harq_process->decodeResult, + A, + A / 8, + G, + nb_re_dmrs, + dmrs_length, + dlsch->dlsch_config.mcs, + dlsch->Nl, + nb_symb_sch, + nb_rb, + dlsch->dlsch_config.qamModOrder, + Coderate); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_COMBINE_SEG, VCD_FUNCTION_OUT); ret = dlsch->last_iteration_cnt; return(ret); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index 75275f5570..cd24114323 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -122,7 +122,7 @@ typedef struct { /// codeword this transport block is mapped to uint8_t codeword; /// HARQ-ACKs - uint8_t ack; + bool decodeResult; /// Last index of LLR buffer that contains information. /// Used for computing LDPC decoder R int llrLen; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 9903075a1d..0d077dfd42 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -620,14 +620,11 @@ typedef struct LDPCDecode_ue_s { NR_UE_DLSCH_t *dlsch; short* dlsch_llr; int dlsch_id; - int harq_pid; int rv_index; - int A; int E; int Kc; int Qm; int Kr_bytes; - int nbSegments; int segment_r; int r_offset; int offset; @@ -636,7 +633,6 @@ 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; static inline void start_meas_nr_ue_phy(PHY_VARS_NR_UE *ue, int meas_index) { diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index a566fe2369..312d5778b3 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -321,7 +321,8 @@ static void configure_dlsch(NR_UE_DLSCH_t *dlsch0, // dlsch0_harq->status not ACTIVE due to false retransmission // Reset the following flag to skip PDSCH procedures in that case and retrasmit harq status dlsch0->active = false; - update_harq_status(mac, current_harq_pid, dlsch0_harq->ack); + LOG_W(NR_MAC, "dlsch0_harq->status not ACTIVE due to false retransmission harq pid: %d\n", current_harq_pid); + update_harq_status(mac, current_harq_pid, dlsch0_harq->decodeResult); } } diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c index b6e528bdb5..b640974892 100644 --- a/openair1/SCHED_NR_UE/harq_nr.c +++ b/openair1/SCHED_NR_UE/harq_nr.c @@ -115,7 +115,7 @@ void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) dl_harq->status = SCH_IDLE; dl_harq->first_rx = 1; dl_harq->DLround = 0; - dl_harq->ack = DL_ACKNACK_NO_SET; + dl_harq->decodeResult = false; } /******************************************************************* diff --git a/openair1/SCHED_NR_UE/harq_nr.h b/openair1/SCHED_NR_UE/harq_nr.h index 4c39772948..39f44c400a 100644 --- a/openair1/SCHED_NR_UE/harq_nr.h +++ b/openair1/SCHED_NR_UE/harq_nr.h @@ -35,13 +35,7 @@ /************** DEFINE ********************************************/ -#define NR_DEFAULT_DLSCH_HARQ_PROCESSES (8) /* TS 38.214 5.1 */ - -#define DL_ACKNACK_NO_SET (2) -#define DL_NACK (0) -#define DL_ACK (1) -#define DL_DAI_NO_SET (0xFF) -#define UL_DAI_NO_SET (DL_DAI_NO_SET) +#define NR_DEFAULT_DLSCH_HARQ_PROCESSES (8) /* TS 38.214 5.1 */ /************** INCLUDE *******************************************/ diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 2e69ff7c71..76fbad3f9e 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -137,10 +137,10 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, if(dlsch0) { NR_DL_UE_HARQ_t *dl_harq0 = &ue->dl_harq_processes[0][dlsch0->dlsch_config.harq_process_nbr]; rx->pdsch_pdu.harq_pid = dlsch0->dlsch_config.harq_process_nbr; - rx->pdsch_pdu.ack_nack = dl_harq0->ack; + rx->pdsch_pdu.ack_nack = dl_harq0->decodeResult; rx->pdsch_pdu.pdu = b; rx->pdsch_pdu.pdu_length = dlsch0->dlsch_config.TBS / 8; - if (dl_harq0->ack) { + if (dl_harq0->decodeResult) { int t = WS_C_RNTI; if (pdu_type == FAPI_NR_RX_PDU_TYPE_RAR) t = WS_RA_RNTI; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 0a4dc1b44b..fd8aa8d5a6 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -982,8 +982,8 @@ int main(int argc, char **argv) NR_gNB_DLSCH_t *gNB_dlsch = &msgDataTx->dlsch[0][0]; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &gNB_dlsch->harq_process.pdsch_pdu.pdsch_pdu_rel15; - - UE_harq_process->ack = 0; + + UE_harq_process->decodeResult = false; round = 0; UE_harq_process->DLround = round; UE_harq_process->first_rx = 1; @@ -996,7 +996,7 @@ int main(int argc, char **argv) memset(Sched_INFO, 0, sizeof(*Sched_INFO)); Sched_INFO->sched_response_id = -1; - while ((roundack==0)) { + while (round < num_rounds && !UE_harq_process->decodeResult) { round_trials[round]++; clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot, &Sched_INFO->DL_req, &Sched_INFO->TX_req, &Sched_INFO->UL_dci_req); @@ -1178,7 +1178,8 @@ int main(int argc, char **argv) printf("errors_bit = %u (trial %d)\n", errors_bit, trial); } roundStats += ((float)round); - if (UE_harq_process->ack==1) effRate += ((float)TBS)/round; + if (UE_harq_process->decodeResult) + effRate += ((float)TBS) / round; } // noise trials roundStats /= ((float)n_trials); diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c index 0c9968ce55..33cd1b3432 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c @@ -277,7 +277,7 @@ int test_pucch_common_config_single_transport_block(PHY_VARS_NR_UE *ue, int gNB_ v_return = -1; } - harq_status->ack = DL_NACK; + harq_status->decodeResult = false; printf("\n => Test : PUCCH format from common config in prach mode: one negative downlink ACKnowledgment \n"); @@ -308,7 +308,7 @@ int test_pucch_common_config_single_transport_block(PHY_VARS_NR_UE *ue, int gNB_ v_return = -1; } - harq_status->ack = DL_NACK; + harq_status->decodeResult = false; printf("\n => Test : PUCCH format from common config in dedicated mode: one positive and one negative downlink ACKnowledgments \n");