From 26118ed860234f0450d8eabadb0973aa327b5a8b Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Thu, 28 Mar 2019 12:37:39 +0100
Subject: [PATCH] bugfix: fix cqi_req usage in UL scheduler

For retransmission, let's use cqi_req used for the 1st transmission.

Maybe incorrect, should check the specs. (In the worst case, we
simply won't decode this transmission at all. No big deal.)
---
 openair2/LAYER2/MAC/defs.h                | 3 +++
 openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 2 ++
 openair2/LAYER2/MAC/mac.h                 | 3 +++
 3 files changed, 8 insertions(+)

diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h
index 2416fab7f1..4e781e5b3f 100644
--- a/openair2/LAYER2/MAC/defs.h
+++ b/openair2/LAYER2/MAC/defs.h
@@ -676,6 +676,9 @@ typedef struct {
   /// Number of Allocated RBs for UL after scheduling
   uint16_t first_rb_ul[8]; // num_max_harq
 
+  /// Is CQI requested for UL after scheduling 1st transmission
+  uint8_t cqi_req[8];         // num_max_harq
+
   /// Cyclic shift for DMRS after scheduling
   uint16_t cshift[8]; // num_max_harq
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
index 4781936850..3b502167ef 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
@@ -1624,6 +1624,7 @@ schedule_ulsch_rnti(module_id_t module_idP,
           /* Store information for possible retransmission */
           UE_template_ptr->nb_rb_ul[harq_pid] = rb_table[rb_table_index];
           UE_template_ptr->first_rb_ul[harq_pid] = first_rb_slice[CC_id];
+          UE_template_ptr->cqi_req[harq_pid] = cqi_req;
           UE_sched_ctrl_ptr->ul_scheduled |= (1 << harq_pid);
 
           if (UE_id == UE_list->head) {
@@ -1811,6 +1812,7 @@ schedule_ulsch_rnti(module_id_t module_idP,
 
           ul_req_index = 0;
           dlsch_flag = 0;
+          cqi_req = UE_template_ptr->cqi_req[harq_pid];
 
           for(ul_req_index = 0; ul_req_index < ul_req_tmp_body->number_of_pdus; ul_req_index++) {
             if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE &&
diff --git a/openair2/LAYER2/MAC/mac.h b/openair2/LAYER2/MAC/mac.h
index fc457c2ee7..2b436a0a04 100644
--- a/openair2/LAYER2/MAC/mac.h
+++ b/openair2/LAYER2/MAC/mac.h
@@ -815,6 +815,9 @@ typedef struct {
     /// Number of Allocated RBs for UL after scheduling
     uint16_t first_rb_ul[8];	// num_max_harq
 
+    /// Is CQI requested for UL after scheduling 1st transmission
+    uint8_t cqi_req[8];         // num_max_harq
+
     /// Cyclic shift for DMRS after scheduling
     uint16_t cshift[8];		// num_max_harq
 
-- 
GitLab