From 95a39f986e28e99201e82d833220bf6c4662c26c Mon Sep 17 00:00:00 2001
From: Robert Schmidt <robert.schmidt@eurecom.fr>
Date: Thu, 10 Dec 2020 15:43:19 +0100
Subject: [PATCH] Remove (unnecessary) num_slots_per_tdd in DLSCH sched

---
 openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c         |  6 ++----
 openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c   | 12 +++++-------
 openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c |  3 +--
 openair2/LAYER2/NR_MAC_gNB/mac_proto.h             |  9 +++------
 openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h            |  3 +--
 5 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
index 1cbcb5fd44..067b8823cd 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
@@ -421,10 +421,8 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
   }
 
   // This schedules the DCI for Downlink and PDSCH
-  if (is_xlsch_in_slot(dlsch_in_slot_bitmap, slot % num_slots_per_tdd)
-      && slot < 10) {
-    nr_schedule_ue_spec(module_idP, frame, slot, num_slots_per_tdd);
-  }
+  if (is_xlsch_in_slot(dlsch_in_slot_bitmap, slot) && slot < 10)
+    nr_schedule_ue_spec(module_idP, frame, slot);
 
 
   if (UE_info->active[UE_id])
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
index 356ad0b433..556e7d4824 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
@@ -374,8 +374,7 @@ uint8_t getN_PRB_DMRS(NR_BWP_Downlink_t *bwp, int numDmrsCdmGrpsNoData) {
 
 void nr_simple_dlsch_preprocessor(module_id_t module_id,
                                   frame_t frame,
-                                  sub_frame_t slot,
-                                  int num_slots_per_tdd) {
+                                  sub_frame_t slot) {
   NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info;
 
   AssertFatal(UE_info->num_UEs <= 1,
@@ -449,7 +448,7 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id,
 
   uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map;
   // for now HARQ PID is fixed and should be the same as in post-processor
-  const int current_harq_pid = slot % num_slots_per_tdd;
+  const int current_harq_pid = slot % 8;
   NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid];
   NR_UE_ret_info_t *retInfo = &sched_ctrl->retInfo[current_harq_pid];
   const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, 275);
@@ -528,12 +527,11 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id,
 
 void nr_schedule_ue_spec(module_id_t module_id,
                          frame_t frame,
-                         sub_frame_t slot,
-                         int num_slots_per_tdd) {
+                         sub_frame_t slot) {
   gNB_MAC_INST *gNB_mac = RC.nrmac[module_id];
 
   /* PREPROCESSOR */
-  gNB_mac->pre_processor_dl(module_id, frame, slot, num_slots_per_tdd);
+  gNB_mac->pre_processor_dl(module_id, frame, slot);
 
   NR_UE_info_t *UE_info = &gNB_mac->UE_info;
 
@@ -581,7 +579,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
                        1 /* nrOfLayers */)
         >> 3;
 
-    const int current_harq_pid = slot % num_slots_per_tdd;
+    const int current_harq_pid = slot % 8;
     NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid];
     NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[0];
     harq->feedback_slot = pucch->ul_slot;
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
index 8004738f80..d74e1c6192 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
@@ -255,8 +255,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t   module_idP,
 /* schedules whole bandwidth for first user, all the time */
 void nr_preprocessor_phytest(module_id_t module_id,
                              frame_t frame,
-                             sub_frame_t slot,
-                             int num_slots_per_tdd)
+                             sub_frame_t slot)
 {
   NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info;
   const int UE_id = 0;
diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
index 964153daa5..d1c3c4983f 100644
--- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
+++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
@@ -77,14 +77,12 @@ int nr_generate_dlsch_pdu(module_id_t Mod_idP,
 
 void nr_schedule_ue_spec(module_id_t module_id,
                          frame_t frame,
-                         sub_frame_t slot,
-                         int num_slots_per_tdd);
+                         sub_frame_t slot);
 
 /* \brief default preprocessor */
 void nr_simple_dlsch_preprocessor(module_id_t module_id,
                                   frame_t frame,
-                                  sub_frame_t slot,
-                                  int num_slots_per_tdd);
+                                  sub_frame_t slot);
 
 void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, uint8_t slots_per_frame);
 
@@ -150,8 +148,7 @@ uint16_t nr_mac_compute_RIV(uint16_t N_RB_DL, uint16_t RBstart, uint16_t Lcrbs);
  * freq resources */
 void nr_preprocessor_phytest(module_id_t module_id,
                              frame_t frame,
-                             sub_frame_t slot,
-                             int num_slots_per_tdd);
+                             sub_frame_t slot);
 /* \brief UL preprocessor for phytest: schedules UE_id 0 with fixed MCS on a
  * fixed set of resources */
 void nr_ul_preprocessor_phytest(module_id_t module_id,
diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
index e2df6faa6b..e153545d04 100644
--- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
+++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
@@ -477,8 +477,7 @@ typedef struct {
 
 typedef void (*nr_pp_impl_dl)(module_id_t mod_id,
                               frame_t frame,
-                              sub_frame_t slot,
-                              int num_slots_per_tdd);
+                              sub_frame_t slot);
 typedef void (*nr_pp_impl_ul)(module_id_t mod_id,
                               frame_t frame,
                               sub_frame_t slot,
-- 
2.26.2