From 0889d799698aeb37bfbd11b3a25925837b246fed Mon Sep 17 00:00:00 2001
From: jftt_wangshanshan <wang.shanshan@cn.fujitsu.com>
Date: Mon, 23 Apr 2018 09:45:08 +0800
Subject: [PATCH] Modify CQI scheduling strategy

---
 openair1/SCHED/phy_procedures_lte_eNb.c        | 6 ++++++
 openair2/LAYER2/MAC/defs.h                     | 1 +
 openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 1 +
 openair2/LAYER2/MAC/eNB_scheduler_ulsch.c      | 3 ++-
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c
index 13c274c2c6..0be8d49a84 100644
--- a/openair1/SCHED/phy_procedures_lte_eNb.c
+++ b/openair1/SCHED/phy_procedures_lte_eNb.c
@@ -1447,6 +1447,12 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
 	fill_ulsch_cqi_indication(eNB,frame,subframe,
 				  ulsch_harq,
 				  ulsch->rnti);
+	        RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag = 0;
+      }else{
+          if(RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag==1){
+              RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_timer=30;
+              LOG_I(PHY,"RM804 Frame %d,Subframe %d, We're supposed to get a cqi here. Set cqi_req_timer to 30.\n",frame,subframe);
+          }
       }
       
       if (ret == (1+MAX_TURBO_ITERATIONS)) {
diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h
index 52d40355a9..3652c84595 100644
--- a/openair2/LAYER2/MAC/defs.h
+++ b/openair2/LAYER2/MAC/defs.h
@@ -864,6 +864,7 @@ typedef struct {
     uint8_t dl_cqi[NFAPI_CC_MAX];
     int32_t uplane_inactivity_timer;
     uint8_t crnti_reconfigurationcomplete_flag;
+    uint8_t cqi_req_flag;
 } UE_sched_ctrl;
 /*! \brief eNB template for the Random access information */
 typedef struct {
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
index 9cc5ef0476..0b5271630f 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
@@ -4625,6 +4625,7 @@ cqi_indication(module_id_t mod_idP, int CC_idP, frame_t frameP,
 	    extract_pusch_csi(mod_idP, CC_idP, UE_id, frameP, subframeP,
 			      pdu, rel9->length);
 
+	    LOG_I(MAC,"Frame %d Subframe %d update CQI:%d\n",frameP,subframeP,sched_ctl->dl_cqi);
 	}
 
 	// timing advance
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
index dfd2e69506..6325e3ef45 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
@@ -1837,6 +1837,7 @@ void schedule_ulsch_rnti(module_id_t   module_idP,
       else if (UE_sched_ctrl->cqi_req_timer>30) {
         cqi_req = 1;
         UE_sched_ctrl->cqi_req_timer=0;
+        UE_sched_ctrl->cqi_req_flag=1;
       }
       else
         cqi_req = 0;
@@ -1894,7 +1895,6 @@ void schedule_ulsch_rnti(module_id_t   module_idP,
               UE_template->mcs_UL[harq_pid]=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs);
               rb_table_index=5; // for PHR
             }
-
             UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=UE_template->mcs_UL[harq_pid];
 
             UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]);
@@ -2071,6 +2071,7 @@ void schedule_ulsch_rnti(module_id_t   module_idP,
             UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb);
             UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=UE_template->TBS_UL[harq_pid];
 
+
             if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED)
               LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n",
                     module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,mcs_rv,first_rb[CC_id],rb_table[rb_table_index],rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid);
-- 
2.26.2