diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 3b5c9ffad4e9b84314ffe03b2d9d8a2b4162db94..d9a0a50b7e8dd832c2f4254bf237703167d0c773 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -365,6 +365,18 @@ void nr_store_dlsch_buffer(module_id_t module_id, } } +void abort_nr_dl_harq(NR_UE_info_t* UE, int8_t harq_pid) { + + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_harq_t *harq = &sched_ctrl->harq_processes[harq_pid]; + + harq->ndi ^= 1; + harq->round = 0; + UE->mac_stats.dl.errors++; + add_tail_nr_list(&sched_ctrl->available_dl_harq, harq_pid); + +} + bool allocate_dl_retransmission(module_id_t module_id, frame_t frame, sub_frame_t slot, @@ -378,6 +390,17 @@ bool allocate_dl_retransmission(module_id_t module_id, NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_sched_pdsch_t *retInfo = &sched_ctrl->harq_processes[current_harq_pid].sched_pdsch; NR_CellGroupConfig_t *cg = UE->CellGroup; + NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; + + //TODO remove this and handle retransmission with old nrOfLayers + // once ps structure is removed + if(ps->nrOfLayers < retInfo->nrOfLayers) { + LOG_W(NR_MAC,"Cannot schedule retransmission. RI changed from %d to %d\n", + retInfo->nrOfLayers, ps->nrOfLayers); + abort_nr_dl_harq(UE, current_harq_pid); + remove_front_nr_list(&sched_ctrl->retrans_dl_harq); + return false; + } NR_BWP_DownlinkDedicated_t *bwpd = cg && @@ -401,7 +424,6 @@ bool allocate_dl_retransmission(module_id_t module_id, const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); int rbStart = 0; // start wrt BWPstart - NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; int rbSize = 0; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); AssertFatal(tda>=0,"Unable to find PDSCH time domain allocation in list\n"); @@ -1355,6 +1377,8 @@ void nr_schedule_ue_spec(module_id_t module_id, /* save which time allocation has been used, to be used on * retransmissions */ harq->sched_pdsch.time_domain_allocation = ps->time_domain_allocation; + /* save nr of layers for retransmissions */ + harq->sched_pdsch.nrOfLayers = ps->nrOfLayers; // ta command is sent, values are reset if (sched_ctrl->ta_apply) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 20057fab13f97684bc9287525b24343ea68f1b76..a57b04668babc9076343dcc561ea2c5cc66bf506 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -826,14 +826,8 @@ static void handle_dl_harq(NR_UE_info_t * UE, harq->ndi ^= 1; } else if (harq->round >= harq_round_max - 1) { - add_tail_nr_list(&UE->UE_sched_ctrl.available_dl_harq, harq_pid); - harq->round = 0; - harq->ndi ^= 1; - - NR_mac_stats_t *stats = &UE->mac_stats; - stats->dl.errors++; - LOG_D(NR_MAC, "retransmission error for UE %04x (total %"PRIu64")\n", UE->rnti, stats->dl.errors); - + abort_nr_dl_harq(UE, harq_pid); + LOG_D(NR_MAC, "retransmission error for UE %04x (total %"PRIu64")\n", UE->rnti, UE->mac_stats.dl.errors); } else { LOG_D(PHY,"NACK for: pid %d, ue %04x\n",harq_pid, UE->rnti); add_tail_nr_list(&UE->UE_sched_ctrl.retrans_dl_harq, harq_pid); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 2229dc32f2d465e145a0d4cc3f15d9db2c0af25e..3fd394abdb7bbb65f528e568163d0c15c20fbbfe 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -522,4 +522,6 @@ size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl); +void abort_nr_dl_harq(NR_UE_info_t* UE, int8_t harq_pid); + #endif /*__LAYER2_NR_MAC_PROTO_H__*/ diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 343b72d6a69c8392cf1999db9e6afb5fde9b3b38..40d16f8e8d2de7e0577d8414e032fae0134fc02f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -440,6 +440,7 @@ typedef struct NR_sched_pdsch { /// only important for retransmissions; otherwise, the TDA in /// NR_pdsch_semi_static_t has precedence int time_domain_allocation; + uint8_t nrOfLayers; } NR_sched_pdsch_t; typedef struct NR_UE_harq {