From 06e700a048e47137eb68bee8d2741fd2f45788ff Mon Sep 17 00:00:00 2001
From: Francesco Mani <francesco.mani@eurecom.fr>
Date: Fri, 31 Jan 2020 16:32:49 +0100
Subject: [PATCH] bitmap for scheduling dlsch and ulsch in UE list

---
 openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 37 +++++++++++++---------
 openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h    |  7 ++--
 2 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
index b561a44d28a..c9b63fe25c8 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
@@ -326,6 +326,11 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
 			       
   protocol_ctxt_t   ctxt;
   int               CC_id;
+  int UE_id;
+  uint64_t *dlsch_in_slot_bitmap=NULL;
+  uint64_t *ulsch_in_slot_bitmap=NULL;
+ 
+  if (phy_test) UE_id=0;
 
   NR_COMMON_channels_t *cc      = RC.nrmac[module_idP]->common_channels;
 
@@ -340,23 +345,25 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
   RC.nrmac[module_idP]->frame    = frame_rxP;
   RC.nrmac[module_idP]->slot     = slot_rxP;
 
-  uint64_t *dlsch_in_slot_bitmap = &RC.nrmac[module_idP]->dlsch_in_slot_bitmap;  // static bitmap signaling which slot in a tdd period contains dlsch
-  uint64_t *ulsch_in_slot_bitmap = &RC.nrmac[module_idP]->ulsch_in_slot_bitmap;  // static bitmap signaling which slot in a tdd period contains ulsch
+  if (phy_test) {
+    dlsch_in_slot_bitmap = &RC.nrmac[module_idP]->UE_list.dlsch_in_slot_bitmap[UE_id];  // static bitmap signaling which slot in a tdd period contains dlsch
+    ulsch_in_slot_bitmap = &RC.nrmac[module_idP]->UE_list.ulsch_in_slot_bitmap[UE_id];  // static bitmap signaling which slot in a tdd period contains ulsch
 
-  // hardcoding dlsch to be in slot 1
-  if (phy_test && !(slot_txP%cc->num_slots_per_tdd)) {
-    if(slot_txP==0)
-      *dlsch_in_slot_bitmap = 0x02;
-    else
-      *dlsch_in_slot_bitmap = 0x00;
-  }
+    // hardcoding dlsch to be in slot 1
+    if (!(slot_txP%cc->num_slots_per_tdd)) {
+      if(slot_txP==0)
+        *dlsch_in_slot_bitmap = 0x02;
+      else
+        *dlsch_in_slot_bitmap = 0x00;
+    }
 
-  // hardcoding ulsch to be in slot 8
-  if (phy_test && !(slot_rxP%cc->num_slots_per_tdd)) {
-    if(slot_rxP==0)
-      *ulsch_in_slot_bitmap = 0x100;
-    else
-      *ulsch_in_slot_bitmap = 0x00;
+    // hardcoding ulsch to be in slot 8
+    if (!(slot_rxP%cc->num_slots_per_tdd)) {
+      if(slot_rxP==0)
+        *ulsch_in_slot_bitmap = 0x100;
+      else
+        *ulsch_in_slot_bitmap = 0x00;
+    }
   }
 
   // Check if there are downlink symbols in the slot, 
diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
index 77501a04870..b9df20d4c20 100644
--- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
+++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
@@ -122,9 +122,11 @@ typedef struct {
   boolean_t active[MAX_MOBILES_PER_GNB];
   rnti_t rnti[MAX_MOBILES_PER_GNB];
   NR_CellGroupConfig_t *secondaryCellGroup[MAX_MOBILES_PER_GNB];
+  uint64_t dlsch_in_slot_bitmap[MAX_MOBILES_PER_GNB];  // static bitmap signaling which slot in a tdd period contains dlsch
+  uint64_t ulsch_in_slot_bitmap[MAX_MOBILES_PER_GNB];  // static bitmap signaling which slot in a tdd period contains ulsch
 } NR_UE_list_t;
 
-/*! \brief top level eNB MAC structure */
+/*! \brief top level gNB MAC structure */
 typedef struct gNB_MAC_INST_s {
   /// Ethernet parameters for northbound midhaul interface
   eth_params_t                    eth_params_n;
@@ -155,9 +157,6 @@ typedef struct gNB_MAC_INST_s {
   nfapi_nr_tx_data_request_t       TX_req[NFAPI_CC_MAX];
   NR_UE_list_t UE_list;
 
-  uint64_t dlsch_in_slot_bitmap;  // static bitmap signaling which slot in a tdd period contains dlsch
-  uint64_t ulsch_in_slot_bitmap;  // static bitmap signaling which slot in a tdd period contains ulsch
-
   /// UL handle
   uint32_t ul_handle;
 
-- 
GitLab