From 13401a5f8cdff36ab20227bb2731303433e5f240 Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Thu, 24 Feb 2022 09:49:47 -0800 Subject: [PATCH] Comments from OAI: This commit include dynamically setting the slots_per_frame value based on configuration. It also includes some comments. Lastly, simplified bug fix in MAC layer related to sched_frame calculation. --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 17 +++++++++-------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 7 ++++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 855b86d24c..f8b6033277 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -1335,9 +1335,11 @@ void set_harq_status(NR_UE_MAC_INST_t *mac, current_harq->dl_frame = frame; current_harq->dl_slot = slot; if (get_softmodem_params()->emulate_l1) { - if (data_toul_fb + slot > 19) { + uint8_t scs = get_softmodem_params()->numerology; + int slots_per_frame = nr_slots_per_frame[scs]; + if (data_toul_fb + slot >= slots_per_frame) { frame = (frame + 1) % 1024; - slot = (data_toul_fb + slot) - 20; + slot = (data_toul_fb + slot) - slots_per_frame; } else { slot = data_toul_fb + slot; @@ -2024,13 +2026,12 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, current_harq = &mac->dl_harq_info[dl_harq_pid]; if (current_harq->active) { + + sched_slot = current_harq->dl_slot + current_harq->feedback_to_ul; sched_frame = current_harq->dl_frame; - if (current_harq->feedback_to_ul + current_harq->dl_slot > 19) { - sched_frame = (sched_frame + 1) % 1024; - sched_slot = (current_harq->feedback_to_ul + current_harq->dl_slot) - slots_per_frame; - } - else { - sched_slot = current_harq->feedback_to_ul + current_harq->dl_slot; + if (sched_slot>=slots_per_frame){ + sched_slot %= slots_per_frame; + sched_frame = (sched_frame + 1) % 1024; } AssertFatal(sched_slot < slots_per_frame, "sched_slot was calculated incorrect %d\n", sched_slot); LOG_D(PHY,"HARQ pid %d is active for %d.%d (dl_slot %d, feedback_to_ul %d, is_common %d\n",dl_harq_pid, sched_frame,sched_slot,current_harq->dl_slot,current_harq->feedback_to_ul,current_harq->is_common); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 699e0e1d71..e9394888f4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -262,9 +262,10 @@ int nr_process_mac_pdu(module_id_t module_idP, //38.321 section 6.1.3.1 //variable length /* Several checks have been added to this function to - ensure that the casting of the pduP is possible. There - is an actual bug here, but it has not been resolved. This - means that the scheduled transport block size is invalid. */ + ensure that the casting of the pduP is possible. There seems + to be a partial PDU at the end of this buffer, so here + we gracefully ignore that by returning 0. See: + https://gitlab.eurecom.fr/oai/openairinterface5g/-/issues/534 */ if (pdu_len < sizeof(NR_MAC_SUBHEADER_SHORT)) return 0; mac_ce_len |= (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;