From 0b9c724ab41fe4656ad96c82f347380b4d6c2541 Mon Sep 17 00:00:00 2001
From: Florian Kaltenberger <florian.kaltenberger@eurecom.fr>
Date: Thu, 27 Nov 2014 11:10:02 +0000
Subject: [PATCH] fixed scheduler for 2 CCs.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6114 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 openair2/LAYER2/MAC/eNB_scheduler_dlsch.c     | 26 +++++++-------
 .../LAYER2/MAC/eNB_scheduler_primitives.c     | 34 ++++++++++---------
 openair2/LAYER2/MAC/eNB_scheduler_ulsch.c     |  8 ++---
 openair2/LAYER2/MAC/extern.h                  |  4 +--
 openair2/LAYER2/MAC/proto.h                   |  4 +--
 openair2/LAYER2/MAC/vars.h                    |  4 +--
 openair2/LAYER2/PDCP_v10.1.0/pdcp.c           |  2 ++
 7 files changed, 44 insertions(+), 38 deletions(-)

diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
index cfd90aac0f0..a1a8b713ccc 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
@@ -71,27 +71,27 @@ extern inline unsigned int taus(void);
 
 void add_ue_dlsch_info(module_id_t module_idP, int CC_id, int UE_id, sub_frame_t subframeP, UE_DLSCH_STATUS status){
 
-  eNB_dlsch_info[module_idP][UE_id].rnti             = UE_RNTI(module_idP,UE_id);
-  //  eNB_dlsch_info[module_idP][ue_mod_idP].weight           = weight;
-  eNB_dlsch_info[module_idP][UE_id].subframe         = subframeP;
-  eNB_dlsch_info[module_idP][UE_id].status           = status;
+  eNB_dlsch_info[module_idP][CC_id][UE_id].rnti             = UE_RNTI(module_idP,UE_id);
+  //  eNB_dlsch_info[module_idP][CC_id][ue_mod_idP].weight           = weight;
+  eNB_dlsch_info[module_idP][CC_id][UE_id].subframe         = subframeP;
+  eNB_dlsch_info[module_idP][CC_id][UE_id].status           = status;
 
-  eNB_dlsch_info[module_idP][UE_id].serving_num++;
+  eNB_dlsch_info[module_idP][CC_id][UE_id].serving_num++;
 
 }
 
-int schedule_next_dlue(module_id_t module_idP, sub_frame_t subframeP){
+int schedule_next_dlue(module_id_t module_idP, int CC_id, sub_frame_t subframeP){
 
   int next_ue;
   UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list;
 
   for (next_ue=UE_list->head; next_ue>=0; next_ue=UE_list->next[next_ue] ){
-    if  (eNB_dlsch_info[module_idP][next_ue].status == S_DL_WAITING)
+    if  (eNB_dlsch_info[module_idP][CC_id][next_ue].status == S_DL_WAITING)
       return next_ue;
   }
   for (next_ue=UE_list->head; next_ue>=0; next_ue=UE_list->next[next_ue] ){
-    if  (eNB_dlsch_info[module_idP][next_ue].status == S_DL_BUFFERED) {
-      eNB_dlsch_info[module_idP][next_ue].status = S_DL_WAITING;
+    if  (eNB_dlsch_info[module_idP][CC_id][next_ue].status == S_DL_BUFFERED) {
+      eNB_dlsch_info[module_idP][CC_id][next_ue].status = S_DL_WAITING;
     }
   }
 
@@ -442,6 +442,7 @@ void schedule_ue_spec(module_id_t   module_idP,
  
 
   for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
+    LOG_D(MAC, "doing schedule_ue_spec for CC_id %d\n",CC_id);
     if (mbsfn_flag[CC_id]>0)
       continue;
     for (UE_id=UE_list->head;UE_id>=0;UE_id=UE_list->next[UE_id]) {
@@ -1182,6 +1183,7 @@ void fill_DLSCH_dci(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP
   start_meas(&eNB->fill_DLSCH_dci);
   vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI,VCD_FUNCTION_IN);
   for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
+    LOG_D(MAC,"Doing fill DCI for CC_id %d\n",CC_id);
 
     if (mbsfn_flagP[CC_id]>0)
       continue;
@@ -1750,11 +1752,11 @@ void fill_DLSCH_dci(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP
 
     // UE specific DCIs
     for (UE_id=UE_list->head;UE_id>=0;UE_id=UE_list->next[UE_id]) {
-      //      printf("UE_id: %d => status %d\n",UE_id,eNB_dlsch_info[module_idP][UE_id].status);
-      if (eNB_dlsch_info[module_idP][UE_id].status == S_DL_SCHEDULED) {
+      LOG_D(MAC,"CC_id %d, UE_id: %d => status %d\n",CC_id,UE_id,eNB_dlsch_info[module_idP][CC_id][UE_id].status);
+      if (eNB_dlsch_info[module_idP][CC_id][UE_id].status == S_DL_SCHEDULED) {
 
 	// clear scheduling flag
-	eNB_dlsch_info[module_idP][UE_id].status = S_DL_WAITING;
+	eNB_dlsch_info[module_idP][CC_id][UE_id].status = S_DL_WAITING;
 	rnti = UE_RNTI(module_idP,UE_id);
 	mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,0);
 	nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid];
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
index 5e6472a9a7a..a8848ca568a 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
@@ -69,27 +69,29 @@
 
 
 void init_ue_sched_info(void){
-  module_id_t i,j;
+  module_id_t i,j,k;
   for (i=0;i<NUMBER_OF_eNB_MAX;i++){
+    for (k=0;i<MAX_NUM_CCs;i++){
       for (j=0;j<NUMBER_OF_UE_MAX;j++){
           // init DL
-          eNB_dlsch_info[i][j].weight           = 0;
-          eNB_dlsch_info[i][j].subframe         = 0;
-          eNB_dlsch_info[i][j].serving_num      = 0;
-          eNB_dlsch_info[i][j].status           = S_DL_NONE;
+          eNB_dlsch_info[i][k][j].weight           = 0;
+          eNB_dlsch_info[i][k][j].subframe         = 0;
+          eNB_dlsch_info[i][k][j].serving_num      = 0;
+          eNB_dlsch_info[i][k][j].status           = S_DL_NONE;
           // init UL
-          eNB_ulsch_info[i][j].subframe         = 0;
-          eNB_ulsch_info[i][j].serving_num      = 0;
-          eNB_ulsch_info[i][j].status           = S_UL_NONE;
+          eNB_ulsch_info[i][k][j].subframe         = 0;
+          eNB_ulsch_info[i][k][j].serving_num      = 0;
+          eNB_ulsch_info[i][k][j].status           = S_UL_NONE;
       }
+    }
   }
 }
 
 
 
-unsigned char get_ue_weight(module_id_t module_idP, int ue_idP){
+unsigned char get_ue_weight(module_id_t module_idP, int CC_id, int ue_idP){
 
-  return(eNB_dlsch_info[module_idP][ue_idP].weight);
+  return(eNB_dlsch_info[module_idP][CC_id][ue_idP].weight);
 
 }
 
@@ -235,8 +237,8 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP) {
       UE_list->UE_template[cc_idP][UE_id].oldNDI[j]    = (j==0)?1:0;   // 1 because first transmission is with format1A (Msg4) for harq_pid 0 
       UE_list->UE_template[cc_idP][UE_id].oldNDI_UL[j] = (j==harq_pidP)?0:1; // 1st transmission is with Msg3;
     }
-    eNB_ulsch_info[mod_idP][UE_id].status = S_UL_WAITING;
-    eNB_dlsch_info[mod_idP][UE_id].status = S_UL_WAITING;
+    eNB_ulsch_info[mod_idP][cc_idP][UE_id].status = S_UL_WAITING;
+    eNB_dlsch_info[mod_idP][cc_idP][UE_id].status = S_UL_WAITING;
     LOG_D(MAC,"[eNB %d] Add UE_id %d on Primary CC_id %d: rnti %x\n",mod_idP,UE_id,cc_idP,rntiP);
     dump_ue_list(UE_list,0);
     return(UE_id);
@@ -266,10 +268,10 @@ int mac_remove_ue(module_id_t mod_idP, int ue_idP) {
   UE_list->UE_template[pCC_id][ue_idP].ul_SR             = 0;
   UE_list->UE_template[pCC_id][ue_idP].rnti              = 0;
   UE_list->UE_template[pCC_id][ue_idP].ul_active         = FALSE;
-  eNB_ulsch_info[mod_idP][ue_idP].rnti                        = 0;
-  eNB_ulsch_info[mod_idP][ue_idP].status                      = S_UL_NONE;
-  eNB_dlsch_info[mod_idP][ue_idP].rnti                        = 0;
-  eNB_dlsch_info[mod_idP][ue_idP].status                      = S_DL_NONE;
+  eNB_ulsch_info[mod_idP][pCC_id][ue_idP].rnti                        = 0;
+  eNB_ulsch_info[mod_idP][pCC_id][ue_idP].status                      = S_UL_NONE;
+  eNB_dlsch_info[mod_idP][pCC_id][ue_idP].rnti                        = 0;
+  eNB_dlsch_info[mod_idP][pCC_id][ue_idP].status                      = S_DL_NONE;
 
   rrc_eNB_free_UE_index(mod_idP,ue_idP);
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
index 637474f7481..416cea7dc08 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
@@ -355,11 +355,11 @@ void adjust_bsr_info(int buffer_occupancy,
 
 void add_ue_ulsch_info(module_id_t module_idP, int CC_id, int UE_id, sub_frame_t subframeP, UE_ULSCH_STATUS status){
 
-  eNB_ulsch_info[module_idP][UE_id].rnti             = UE_RNTI(module_idP,UE_id);
-  eNB_ulsch_info[module_idP][UE_id].subframe         = subframeP;
-  eNB_ulsch_info[module_idP][UE_id].status           = status;
+  eNB_ulsch_info[module_idP][CC_id][UE_id].rnti             = UE_RNTI(module_idP,UE_id);
+  eNB_ulsch_info[module_idP][CC_id][UE_id].subframe         = subframeP;
+  eNB_ulsch_info[module_idP][CC_id][UE_id].status           = status;
 
-  eNB_ulsch_info[module_idP][UE_id].serving_num++;
+  eNB_ulsch_info[module_idP][CC_id][UE_id].serving_num++;
 
 }
 
diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/extern.h
index 20b41da210d..bf53e4f7271 100644
--- a/openair2/LAYER2/MAC/extern.h
+++ b/openair2/LAYER2/MAC/extern.h
@@ -59,8 +59,8 @@ extern eNB_MAC_INST *eNB_mac_inst;
 extern MAC_RLC_XFACE *Mac_rlc_xface;
 extern uint8_t Is_rrc_registered;
 
-extern eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 
-extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 
+extern eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 
+extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 
 
 
 
diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h
index a0329423fa3..362bb543c46 100644
--- a/openair2/LAYER2/MAC/proto.h
+++ b/openair2/LAYER2/MAC/proto.h
@@ -332,7 +332,7 @@ module_id_t schedule_next_ulue(module_id_t module_idP, int UE_id,sub_frame_t sub
 @param subframe Subframe number on which to act
 @returns UE index that is to be scheduled if needed/room
 */
-int schedule_next_dlue(module_id_t module_idP, sub_frame_t subframe);
+int schedule_next_dlue(module_id_t module_idP, int CC_id, sub_frame_t subframe);
 
 /* \brief Allocates a set of PRBS for a particular UE.  This is a simple function for the moment, later it should process frequency-domain CQI information and/or PMI information.  Currently it just returns the first PRBS that are available in the subframe based on the number requested.
 @param UE_id Index of UE on which to act
@@ -359,7 +359,7 @@ uint32_t req_new_ulsch(module_id_t module_idP);
 */
 uint32_t ue_get_SR(module_id_t module_idP, int CC_id,frame_t frameP, uint8_t eNB_id,rnti_t rnti,sub_frame_t subframe);
 
-uint8_t get_ue_weight(module_id_t module_idP, int UE_id);
+uint8_t get_ue_weight(module_id_t module_idP, int CC_id, int UE_id);
 
 // UE functions
 void mac_out_of_sync_ind(module_id_t module_idP, frame_t frameP, uint16_t CH_index);
diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/vars.h
index 0ba37dc6d9a..fe44ac49d77 100644
--- a/openair2/LAYER2/MAC/vars.h
+++ b/openair2/LAYER2/MAC/vars.h
@@ -66,8 +66,8 @@ int pCC_id[NUMBER_OF_eNB_MAX];
 
 
 
-eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 
-eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 
+eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 
+eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 
 
 /*
 #ifndef USER_MODE
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
index aed6941522d..9bcc7edf872 100755
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
@@ -650,9 +650,11 @@ boolean_t pdcp_data_ind(
           pdcp_p->last_submitted_pdcp_rx_sn = sequence_number;
       }
    
+#if defined(DEBUG_PDCP_PAYLOAD)
       rlc_util_print_hex_octets(PDCP,
                                 (unsigned char*)&sdu_buffer_pP->data[payload_offset],
                                 sdu_buffer_sizeP - payload_offset);
+#endif
 
       src_id = (enb_flagP == ENB_FLAG_NO) ?  enb_mod_idP : ue_mod_idP +   NB_eNB_INST;
       dst_id = (enb_flagP == ENB_FLAG_NO) ? ue_mod_idP +  NB_eNB_INST: enb_mod_idP;
-- 
GitLab