From a2bf8f478ab2ee3a1eb9c30b26d73e56f24eace6 Mon Sep 17 00:00:00 2001
From: Robert Schmidt <robert.schmidt@eurecom.fr>
Date: Tue, 29 Sep 2020 18:06:43 +0200
Subject: [PATCH] Add configurable UE as param for nr_generate_dlsch_pdu()

---
 openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c   | 8 ++------
 openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 1 +
 openair2/LAYER2/NR_MAC_gNB/mac_proto.h             | 1 +
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
index 85c56456158..93c9e32842b 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
@@ -58,6 +58,7 @@
 //#define SIZE_OF_POINTER sizeof (void *)
 
 int nr_generate_dlsch_pdu(module_id_t module_idP,
+                          NR_UE_sched_ctrl_t *ue_sched_ctl,
                           unsigned char *sdus_payload,
                           unsigned char *mac_pdu,
                           unsigned char num_sdus,
@@ -74,12 +75,6 @@ int nr_generate_dlsch_pdu(module_id_t module_idP,
   // MAC CEs
   uint8_t mac_header_control_elements[16], *ce_ptr;
   ce_ptr = &mac_header_control_elements[0];
-  uint16_t UE_id = 0; //TODO need to get as a function parameter or need to invoke api to UE_id using module Id and RNTI
-  gNB_MAC_INST *gNB_mac = RC.nrmac[module_idP];
-  NR_UE_info_t *UE_info = &gNB_mac->UE_info;
-  NR_UE_sched_ctrl_t *ue_sched_ctl = NULL;
-  //NR_CellGroupConfig_t *config = UE_info->secondaryCellGroup[UE_id];
-  ue_sched_ctl = &(UE_info->UE_sched_ctrl[UE_id]);
 
   // 1) Compute MAC CE and related subheaders
 
@@ -768,6 +763,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
 
       const int offset = nr_generate_dlsch_pdu(
           module_id,
+          sched_ctrl,
           (unsigned char *)mac_sdus,
           (unsigned char *)buf,
           num_sdus, // num_sdus
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
index 9f69edcdfa3..450ffa2268f 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
@@ -742,6 +742,7 @@ void nr_schedule_uss_dlsch_phytest(module_id_t   module_idP,
     }
 
     offset = nr_generate_dlsch_pdu(module_idP,
+                                   &UE_info->UE_sched_ctrl[UE_id],
                                    (unsigned char *) mac_sdus,
                                    (unsigned char *) gNB_mac->UE_info.DLSCH_pdu[0][0].payload[0],
                                    num_sdus, //num_sdus
diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
index 420a37bd524..f636a27300d 100644
--- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
+++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
@@ -67,6 +67,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
 			       frame_t frame_rxP, sub_frame_t slot_rxP);
 
 int nr_generate_dlsch_pdu(module_id_t Mod_idP,
+                          NR_UE_sched_ctrl_t *ue_sched_ctl,
                           unsigned char *sdus_payload,
                           unsigned char *mac_pdu,
                           unsigned char num_sdus,
-- 
GitLab