From b76eb194715e702e621d00c19b5d83d9307b36ae Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Fri, 19 Jul 2024 16:09:04 +0200 Subject: [PATCH] gNB: refactor code to handle end of using a specific HARQ process - finish_nr_dl_harq() and finish_nr_ul_harq() --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 7 +----- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 23 +++++++++--------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 9 ++++--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 24 ++++++++++--------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 1 + 5 files changed, 31 insertions(+), 33 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 9f7199d7d5..c51e1209b5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1888,12 +1888,7 @@ static void nr_generate_Msg4(module_id_t module_idP, NR_sched_pucch_t *pucch = NULL; DevAssert(!harq->is_waiting); if (alloc < 0) { - add_tail_nr_list(&sched_ctrl->available_dl_harq, current_harq_pid); - harq->feedback_frame = -1; - harq->feedback_slot = -1; - harq->is_waiting = false; - harq->ndi ^= 1; - harq->round = 0; + finish_nr_dl_harq(sched_ctrl, current_harq_pid); } else { pucch = &sched_ctrl->sched_pucch[alloc]; add_tail_nr_list(&sched_ctrl->feedback_dl_harq, current_harq_pid); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 7e80ff7dfd..cd4fc9b197 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -371,17 +371,23 @@ static void nr_store_dlsch_buffer(module_id_t module_id, frame_t frame, sub_fram } } -void abort_nr_dl_harq(NR_UE_info_t* UE, int8_t harq_pid) +void finish_nr_dl_harq(NR_UE_sched_ctrl_t *sched_ctrl, int harq_pid) { - /* already mutex protected through handle_dl_harq() */ - 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); + add_tail_nr_list(&sched_ctrl->available_dl_harq, harq_pid); +} + +void abort_nr_dl_harq(NR_UE_info_t* UE, int8_t harq_pid) +{ + /* already mutex protected through handle_dl_harq() */ + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + + finish_nr_dl_harq(sched_ctrl, harq_pid); + UE->mac_stats.dl.errors++; } static void get_start_stop_allocation(gNB_MAC_INST *mac, @@ -1008,12 +1014,7 @@ void nr_schedule_ue_spec(module_id_t module_id, NR_sched_pucch_t *pucch = NULL; DevAssert(!harq->is_waiting); if (sched_pdsch->pucch_allocation < 0) { - add_tail_nr_list(&sched_ctrl->available_dl_harq, current_harq_pid); - harq->feedback_frame = -1; - harq->feedback_slot = -1; - harq->is_waiting = false; - harq->ndi ^= 1; - harq->round = 0; + finish_nr_dl_harq(sched_ctrl, current_harq_pid); } else { pucch = &sched_ctrl->sched_pucch[sched_pdsch->pucch_allocation]; add_tail_nr_list(&sched_ctrl->feedback_dl_harq, current_harq_pid); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 2d59e72db2..3de5c1ea7a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -385,19 +385,18 @@ static void handle_dl_harq(NR_UE_info_t * UE, bool success, int harq_round_max) { - NR_UE_harq_t *harq = &UE->UE_sched_ctrl.harq_processes[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->feedback_slot = -1; harq->is_waiting = false; if (success) { - add_tail_nr_list(&UE->UE_sched_ctrl.available_dl_harq, harq_pid); - harq->round = 0; - harq->ndi ^= 1; + finish_nr_dl_harq(sched_ctrl, harq_pid); } else if (harq->round >= harq_round_max - 1) { 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); + add_tail_nr_list(&sched_ctrl->retrans_dl_harq, harq_pid); harq->round++; } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 02770f2b2d..d5a03c4cd7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -511,15 +511,23 @@ static int nr_process_mac_pdu(instance_t module_idP, return 0; } +static void finish_nr_ul_harq(NR_UE_sched_ctrl_t *sched_ctrl, int harq_pid) +{ + NR_UE_ul_harq_t *harq = &sched_ctrl->ul_harq_processes[harq_pid]; + + harq->ndi ^= 1; + harq->round = 0; + + add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); +} + static void abort_nr_ul_harq(NR_UE_info_t *UE, int8_t harq_pid) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_UE_ul_harq_t *harq = &sched_ctrl->ul_harq_processes[harq_pid]; - harq->ndi ^= 1; - harq->round = 0; + finish_nr_ul_harq(sched_ctrl, harq_pid); UE->mac_stats.ul.errors++; - add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); /* the transmission failed: the UE won't send the data we expected initially, * so retrieve to correctly schedule after next BSR */ @@ -602,13 +610,11 @@ void handle_nr_ul_harq(const int CC_idP, harq->feedback_slot = -1; harq->is_waiting = false; if (!crc_pdu->tb_crc_status) { - harq->ndi ^= 1; - harq->round = 0; + finish_nr_ul_harq(sched_ctrl, harq_pid); LOG_D(NR_MAC, "Ulharq id %d crc passed for RNTI %04x\n", harq_pid, crc_pdu->rnti); - add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); } else if (harq->round >= RC.nrmac[mod_id]->ul_bler.harq_round_max - 1) { abort_nr_ul_harq(UE, harq_pid); LOG_D(NR_MAC, @@ -2268,11 +2274,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot, n NR_UE_ul_harq_t *cur_harq = &sched_ctrl->ul_harq_processes[harq_id]; DevAssert(!cur_harq->is_waiting); if (nr_mac->radio_config.disable_harq) { - add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_id); - cur_harq->feedback_slot = -1; - cur_harq->is_waiting = false; - cur_harq->ndi ^= 1; - cur_harq->round = 0; + finish_nr_ul_harq(sched_ctrl, harq_id); } else { add_tail_nr_list(&sched_ctrl->feedback_ul_harq, harq_id); cur_harq->feedback_slot = sched_pusch->slot; diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 5c998f4d2a..84f06c873c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -433,6 +433,7 @@ long get_lcid_from_srbid(int srb_id); void prepare_initial_ul_rrc_message(gNB_MAC_INST *mac, NR_UE_info_t *UE); void send_initial_ul_rrc_message(int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *data); +void finish_nr_dl_harq(NR_UE_sched_ctrl_t *sched_ctrl, int harq_pid); void abort_nr_dl_harq(NR_UE_info_t* UE, int8_t harq_pid); void nr_mac_trigger_release_timer(NR_UE_sched_ctrl_t *sched_ctrl, NR_SubcarrierSpacing_t subcarrier_spacing);