diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c index 1e763ece15..e7863d3820 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c @@ -72,7 +72,8 @@ void nr_fill_ulsch(PHY_VARS_gNB *gNB, int frame, int slot, nfapi_nr_pusch_pdu_t ulsch->slot = slot; NR_UL_gNB_HARQ_t *harq = ulsch->harq_process; - harq->new_rx = ulsch_pdu->pusch_data.new_data_indicator; + if (ulsch_pdu->pusch_data.new_data_indicator) + harq->harq_to_be_cleared = true; LOG_D(PHY, "%d.%d RNTI %x HARQ PID %d new data indicator %d\n", frame, @@ -80,7 +81,8 @@ void nr_fill_ulsch(PHY_VARS_gNB *gNB, int frame, int slot, nfapi_nr_pusch_pdu_t ulsch_pdu->rnti, harq_pid, ulsch_pdu->pusch_data.new_data_indicator); - if (harq->new_rx) + + if (ulsch_pdu->pusch_data.new_data_indicator) harq->round = 0; else harq->round++; diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index be7de7baea..410ffc89d5 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -76,6 +76,7 @@ void free_gNB_ulsch(NR_gNB_ULSCH_t *ulsch, uint16_t N_RB_UL) } free_and_zero(ulsch->harq_process->c); free_and_zero(ulsch->harq_process->d); + free_and_zero(ulsch->harq_process->d_to_be_cleared); free_and_zero(ulsch->harq_process); ulsch->harq_process = NULL; } @@ -107,6 +108,8 @@ NR_gNB_ULSCH_t new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL) harq->c[r] = malloc16_clear(8448 * sizeof(*harq->c[r])); harq->d[r] = malloc16_clear(68 * 384 * sizeof(*harq->d[r])); } + harq->d_to_be_cleared = calloc(a_segments, sizeof(bool)); + AssertFatal(harq->d_to_be_cleared != NULL, "out of memory\n"); return(ulsch); } @@ -187,7 +190,7 @@ NR_gNB_ULSCH_t new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL) harq_e, ulsch_harq->C, rv_index, - ulsch_harq->new_rx, + ulsch_harq->d_to_be_cleared[r], E, ulsch_harq->F, Kr - ulsch_harq->F - 2 * (p_decoderParms->Z)) @@ -201,6 +204,8 @@ NR_gNB_ULSCH_t new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL) stop_meas(&phy_vars_gNB->ulsch_rate_unmatching_stats); } + ulsch_harq->d_to_be_cleared[r] = false; + memset(ulsch_harq->c[r], 0, Kr_bytes); if (ulsch_harq->C == 1) { @@ -312,7 +317,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, float Coderate = (float) pusch_pdu->target_code_rate / 10240.0f; LOG_D(PHY,"ULSCH Decoding, harq_pid %d rnti %x TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, Coderate %f RV %d round %d new RX %d\n", - harq_pid, ulsch->rnti, A, G, mcs, n_layers, nb_rb, Qm, Coderate, pusch_pdu->pusch_data.rv_index, harq_process->round, harq_process->new_rx); + harq_pid, ulsch->rnti, A, G, mcs, n_layers, nb_rb, Qm, Coderate, pusch_pdu->pusch_data.rv_index, harq_process->round, harq_process->harq_to_be_cleared); t_nrLDPC_dec_params decParams = {0}; decParams.BG = pusch_pdu->maintenance_parms_v3.ldpcBaseGraph; int kc; @@ -330,7 +335,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, stats->ulsch_stats.power[aarx] = dB_fixed_x10(pusch->ulsch_power[aarx]); stats->ulsch_stats.noise_power[aarx] = dB_fixed_x10(pusch->ulsch_noise_power[aarx]); } - if (harq_process->new_rx == 0) { + if (!harq_process->harq_to_be_cleared) { stats->ulsch_stats.current_Qm = Qm; stats->ulsch_stats.current_RI = n_layers; stats->ulsch_stats.total_bytes_tx += harq_process->TBS; @@ -383,6 +388,13 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, #ifdef DEBUG_ULSCH_DECODING printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K); #endif + + if (harq_process->harq_to_be_cleared) { + for (int r = 0; r < harq_process->C; r++) + harq_process->d_to_be_cleared[r] = true; + harq_process->harq_to_be_cleared = false; + } + Kr = harq_process->K; Kr_bytes = Kr >> 3; @@ -454,7 +466,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, harq_e, harq_process->C, pusch_pdu->pusch_data.rv_index, - harq_process->new_rx, + harq_process->d_to_be_cleared[r], E, harq_process->F, Kr - harq_process->F - 2 * (decParams.Z)) @@ -464,6 +476,8 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, return 1; } + harq_process->d_to_be_cleared[r] = false; + // set first 2*Z_c bits to zeros memset(&z[0], 0, 2 * harq_process->Z * sizeof(int16_t)); // set Filler bits diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 1fa59ed20b..1c248bc4a9 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -192,6 +192,9 @@ typedef struct { uint8_t round; bool new_rx; /////////////////////// ulsch decoding /////////////////////// + /// flag used to clear d properly (together with d_to_be_cleared below) + /// set to true in nr_fill_ulsch() when new_data_indicator is received + bool harq_to_be_cleared; /// Transport block size (This is A from 38.212 V15.4.0 section 5.1) uint32_t TBS; /// Pointer to the payload (38.212 V15.4.0 section 5.1) @@ -208,6 +211,10 @@ typedef struct { uint32_t C; /// Pointers to code blocks after LDPC coding (38.212 V15.4.0 section 5.3.2) int16_t **d; + /// flag used to clear d properly (together with harq_to_be_cleared above) + /// set to true in nr_ulsch_decoding() when harq_to_be_cleared is true + /// when true, clear d in the next call to function nr_rate_matching_ldpc_rx() + bool *d_to_be_cleared; /// LDPC lifting size (38.212 V15.4.0 table 5.3.2-1) uint32_t Z; /// Number of bits in each code block after rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1)