From 0e1768d023991ce7762d24ad8ea0ea68c3c2c0dc Mon Sep 17 00:00:00 2001
From: Melissa Elkadi <melissa@episci.com>
Date: Tue, 21 Sep 2021 13:03:28 -0700
Subject: [PATCH] ul_tti_future SFN was not being updated correctly

The future frame was not being updated correctly
when multiple slot indications were coming in
at nearly the same time. The VNF would not handle
slot indications that come very close in time to
one another. This was causing the future SFN to
not get updated as expected.

Additionally, there is a portion of the ack/nack
scheduling where code was added to advance the
pucch->ul_slot. This code would occasionally return
a new ul_slot that is greater than 19. I am not sure
what this code was originally intended to do, but for
now, I modified it to ensure that the ul_slot stays
between [0, 19] and if it is above 19 it will wrap
and incrament the frame.
---
 nfapi/open-nFAPI/vnf/src/vnf_p7.c              | 1 +
 openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7.c b/nfapi/open-nFAPI/vnf/src/vnf_p7.c
index cc887ad9ed8..b323fd89362 100644
--- a/nfapi/open-nFAPI/vnf/src/vnf_p7.c
+++ b/nfapi/open-nFAPI/vnf/src/vnf_p7.c
@@ -2528,6 +2528,7 @@ int vnf_nr_p7_read_dispatch_message(vnf_p7_t* vnf_p7)
 			if(recvfrom_result > 0)
 			{
 				vnf_nr_handle_p7_message(vnf_p7->rx_message_buffer, recvfrom_result, vnf_p7);
+				recvfrom_result = -1;
 			}
 			else
 			{
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c
index 9cb06bdd218..7a329000819 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c
@@ -1285,6 +1285,10 @@ int nr_acknack_scheduling(int mod_id,
 
   // advance ul_slot if it is not reachable by UE
   pucch->ul_slot = max(pucch->ul_slot, slot + pdsch_to_harq_feedback[0]);
+  if (pucch->ul_slot > 19) {
+    pucch->ul_slot = pucch->ul_slot % 20;
+    pucch->frame = (pucch->frame + 1) % 1024;
+  }
 
   // Find the right timing_indicator value.
   int i = 0;
-- 
GitLab