From bfb6e407f2a11e0cce2b8f72730e28da97be1f35 Mon Sep 17 00:00:00 2001 From: francescomani Date: Sun, 30 Jun 2024 10:41:36 +0200 Subject: [PATCH 1/2] schedule msg3 retransmission for no signal scenario --- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 2 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 19 +++++-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 56 +++++++++---------- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 1d842e5414..6c57130b3d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -119,7 +119,7 @@ static bool nr_ue_postDecode(PHY_VARS_NR_UE *phy_vars_ue, LOG_D(PHY, "DLSCH received nok \n"); return true; //stop } - const int sz=A/8; + 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; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 8b9134f4a0..a12d203ae7 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -276,10 +276,12 @@ static void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) bool decodeSuccess = (rdata->decodeIterations <= rdata->decoderParms.numMaxIter); ulsch_harq->processedSegments++; LOG_D(PHY, - "processing result of segment: %d, processed %d/%d\n", + "processing result of segment: %d, processed %d/%d, %s\n", rdata->segment_r, ulsch_harq->processedSegments, - rdata->nbSegments); + rdata->nbSegments, + decodeSuccess ? "Decoded Successfully" : "Decoding Unsuccessful"); + if (decodeSuccess) { memcpy(ulsch_harq->b + rdata->offset, ulsch_harq->c[r], rdata->Kr_bytes - (ulsch_harq->F >> 3) - ((ulsch_harq->C > 1) ? 3 : 0)); @@ -466,11 +468,16 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, // put timing advance command in 0..63 range timing_advance_update += 31; + timing_advance_update = max(timing_advance_update, 0); + timing_advance_update = min(timing_advance_update, 63); - if (timing_advance_update < 0) timing_advance_update = 0; - if (timing_advance_update > 63) timing_advance_update = 63; - - if (crc_flag == 0) LOG_D(PHY, "%d.%d : Received PUSCH : Estimated timing advance PUSCH is = %d, timing_advance_update is %d \n", frame,slot_rx,sync_pos,timing_advance_update); + if (crc_flag == 0) + LOG_D(PHY, + "%d.%d : Received PUSCH : Estimated timing advance PUSCH is = %d, timing_advance_update is %d \n", + frame, + slot_rx, + sync_pos, + timing_advance_update); // estimate UL_CQI for MAC int SNRtimes10 = diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 820eba2b5b..9869c52914 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -390,7 +390,7 @@ static int nr_process_mac_pdu(instance_t module_idP, // fixed length mac_subheader_len = 1; - if ( rx_lcid == UL_SCH_LCID_CCCH1 ) { + if (rx_lcid == UL_SCH_LCID_CCCH1) { // RRCResumeRequest1 message includes the full I-RNTI and has a size of 8 bytes mac_len = 8; @@ -615,6 +615,26 @@ void handle_nr_ul_harq(const int CC_idP, NR_SCHED_UNLOCK(&nrmac->sched_lock); } +static void handle_msg3_failed_rx(NR_RA_t *ra, int i, int harq_round_max) +{ + // for CFRA (NSA) do not schedule retransmission of msg3 + if (ra->cfra) { + LOG_D(NR_MAC, "Random Access %i failed at state %s (NSA msg3 reception failed)\n", i, nrra_text[ra->ra_state]); + nr_clear_ra_proc(ra); + return; + } + + if (ra->msg3_round >= harq_round_max - 1) { + LOG_W(NR_MAC, "Random Access %i failed at state %s (Reached msg3 max harq rounds)\n", i, nrra_text[ra->ra_state]); + nr_clear_ra_proc(ra); + return; + } + + LOG_D(NR_MAC, "Random Access %i Msg3 CRC did not pass\n", i); + ra->msg3_round++; + ra->ra_state = nrRA_Msg3_retransmission; +} + /* * When data are received on PHY and transmitted to MAC */ @@ -714,7 +734,7 @@ static void _nr_rx_sdu(const module_id_t gnb_mod_idP, #endif - if (sduP != NULL){ + if (sduP != NULL) { LOG_D(NR_MAC, "Received PDU at MAC gNB \n"); UE->UE_sched_ctrl.pusch_consecutive_dtx_cnt = 0; @@ -728,7 +748,7 @@ static void _nr_rx_sdu(const module_id_t gnb_mod_idP, else { NR_UE_ul_harq_t *cur_harq = &UE_scheduling_control->ul_harq_processes[harq_pid]; /* reduce sched_ul_bytes when cur_harq->round == 3 */ - if (cur_harq->round == 3){ + if (cur_harq->round == 3) { const uint32_t tb_size = UE_scheduling_control->ul_harq_processes[harq_pid].sched_pusch.tb_size; UE_scheduling_control->sched_ul_bytes -= tb_size; if (UE_scheduling_control->sched_ul_bytes < 0) @@ -747,20 +767,16 @@ static void _nr_rx_sdu(const module_id_t gnb_mod_idP, nr_mac_trigger_ul_failure(&UE->UE_sched_ctrl, UE->current_UL_BWP.scs); } } - } else if(sduP) { + } else if (sduP) { bool no_sig = true; for (int k = 0; k < sdu_lenP; k++) { - if(sduP[k]!=0) { + if(sduP[k] != 0) { no_sig = false; break; } } - if(no_sig) { - LOG_W(NR_MAC, "No signal\n"); - } - T(T_GNB_MAC_UL_PDU_WITH_DATA, T_INT(gnb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(slotP), T_INT(-1) /* harq_pid */, T_BUFFER(sduP, sdu_lenP)); @@ -774,8 +790,8 @@ static void _nr_rx_sdu(const module_id_t gnb_mod_idP, continue; if (no_sig) { - LOG_D(NR_MAC, "Random Access %i failed at state %s (no signal)\n", i, nrra_text[ra->ra_state]); - nr_clear_ra_proc(ra); + LOG_W(NR_MAC, "Random Access %i ULSCH with no signal\n", i); + handle_msg3_failed_rx(ra, i, gNB_mac->ul_bler.harq_round_max); continue; } @@ -912,23 +928,7 @@ static void _nr_rx_sdu(const module_id_t gnb_mod_idP, if( (frameP!=ra->Msg3_frame) || (slotP!=ra->Msg3_slot)) continue; - // for CFRA (NSA) do not schedule retransmission of msg3 - if (ra->cfra) { - LOG_D(NR_MAC, "Random Access %i failed at state %s (NSA msg3 reception failed)\n", i, nrra_text[ra->ra_state]); - nr_clear_ra_proc(ra); - return; - } - - if (ra->msg3_round >= gNB_mac->ul_bler.harq_round_max - 1) { - LOG_W(NR_MAC, "Random Access %i failed at state %s (Reached msg3 max harq rounds)\n", i, nrra_text[ra->ra_state]); - nr_clear_ra_proc(ra); - return; - } - - LOG_D(NR_MAC, "Random Access %i Msg3 CRC did not pass)\n", i); - - ra->msg3_round++; - ra->ra_state = nrRA_Msg3_retransmission; + handle_msg3_failed_rx(ra, i, gNB_mac->ul_bler.harq_round_max); } } } From ff0007cd94982cd94acfa972122799f9e23101f0 Mon Sep 17 00:00:00 2001 From: francescomani Date: Sun, 30 Jun 2024 11:02:13 +0200 Subject: [PATCH 2/2] tentative fix for wrong handling of ulsch decode failure --- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 1 + openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 4c35ee9933..517167cdb6 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -180,6 +180,7 @@ static void nr_processULSegment(void *arg) LOG_E(PHY, "ulsch_decoding.c: Problem in rate_matching\n"); rdata->decodeIterations = max_ldpc_iterations + 1; + set_abort(&ulsch_harq->abort_decode, true); return; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 9869c52914..7b407635d9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1935,7 +1935,7 @@ static void pf_ul(module_id_t module_id, UEsched_t *iterator=UE_sched; /* Loop UE_sched to find max coeff and allocate transmission */ - while (remainUEs> 0 && n_rb_sched >= min_rb && iterator->UE != NULL) { + while (remainUEs > 0 && n_rb_sched >= min_rb && iterator->UE != NULL) { NR_UE_sched_ctrl_t *sched_ctrl = &iterator->UE->UE_sched_ctrl; int CCEIndex = get_cce_index(nrmac,