From fd9f5d2d2cf73f5194875666fbbd94ddd1aa4d4f Mon Sep 17 00:00:00 2001
From: Robert Schmidt <robert.schmidt@eurecom.fr>
Date: Wed, 14 Oct 2020 12:56:10 +0200
Subject: [PATCH] Use function pointer to call pre-processor

---
 openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 5 +++--
 openair2/LAYER2/NR_MAC_gNB/mac_proto.h           | 6 ++++++
 openair2/LAYER2/NR_MAC_gNB/main.c                | 2 ++
 openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h          | 8 ++++++++
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
index 188f4f774f0..31571a96667 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
@@ -626,10 +626,11 @@ void nr_schedule_ue_spec(module_id_t module_id,
                          frame_t frame,
                          sub_frame_t slot,
                          int num_slots_per_tdd) {
+  gNB_MAC_INST *gNB_mac = RC.nrmac[module_id];
+
   /* PREPROCESSOR */
-  nr_simple_dlsch_preprocessor(module_id, frame, slot, num_slots_per_tdd);
+  gNB_mac->pre_processor_dl(module_id, frame, slot, num_slots_per_tdd);
 
-  gNB_MAC_INST *gNB_mac = RC.nrmac[module_id];
   NR_UE_info_t *UE_info = &gNB_mac->UE_info;
 
   const int CC_id = 0;
diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
index c67b7ce07b8..118c68d91cc 100644
--- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
+++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
@@ -80,6 +80,12 @@ void nr_schedule_ue_spec(module_id_t module_id,
                          sub_frame_t slot,
                          int num_slots_per_tdd);
 
+/* \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);
+
 void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP);
 
 /////// Random Access MAC-PHY interface functions and primitives ///////
diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c
index 7df00f15f1c..eb28ef3770a 100644
--- a/openair2/LAYER2/NR_MAC_gNB/main.c
+++ b/openair2/LAYER2/NR_MAC_gNB/main.c
@@ -82,6 +82,8 @@ void mac_top_init_gNB(void)
         
       RC.nrmac[i]->ul_handle = 0;
 
+      RC.nrmac[i]->pre_processor_dl = nr_simple_dlsch_preprocessor;
+
     }//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++)
 
     AssertFatal(rlc_module_init(1) == 0,"Could not initialize RLC layer\n");
diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
index 889e50454c5..6e9c5472768 100644
--- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
+++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
@@ -427,6 +427,11 @@ typedef struct {
   uint8_t UE_beam_index[MAX_MOBILES_PER_GNB];
 } NR_UE_info_t;
 
+typedef void (*nr_pp_impl_dl)(module_id_t mod_id,
+                              frame_t frame,
+                              sub_frame_t slot,
+                              int num_slots_per_tdd);
+
 /*! \brief top level eNB MAC structure */
 typedef struct gNB_MAC_INST_s {
   /// Ethernet parameters for northbound midhaul interface
@@ -489,6 +494,9 @@ typedef struct gNB_MAC_INST_s {
   int cce_list[MAX_NUM_BWP][MAX_NUM_CORESET][MAX_NUM_CCE];
   /// current slot
   int current_slot;
+
+  /// DL preprocessor for differentiated scheduling
+  nr_pp_impl_dl pre_processor_dl;
 } gNB_MAC_INST;
 
 #endif /*__LAYER2_NR_MAC_GNB_H__ */
-- 
GitLab