From 975342399d85775b9a8e48295de51aa505cc6bbd Mon Sep 17 00:00:00 2001
From: "Raymond.Knopp" <raymond.knopp@eurecom.fr>
Date: Tue, 27 Dec 2016 21:31:11 +0100
Subject: [PATCH] bugfix for DCCH2/SRB2 in eNB_scheduler_dlsch.c,
 demultiplexing SIMD alignment issue in ulsch_decoding.c, IF5 fronthaul
 modification in lte-enb.c

---
 openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 21 ++++++++++++++---
 openair2/LAYER2/MAC/eNB_scheduler_dlsch.c   | 25 +++++++++++----------
 targets/RT/USER/lte-enb.c                   |  4 ++--
 3 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
index 68f3abc094..8edb1eaf94 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
@@ -1440,7 +1440,7 @@ unsigned int  ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,
       
       j2+=Q_m;
     }
-
+    /* To be improved according to alignment of j2
 #if defined(__x86_64__)||defined(__i386__)
 #ifndef __AVX2__
     for (iprime=0; iprime<G;iprime+=8,j2+=8)
@@ -1452,9 +1452,24 @@ unsigned int  ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,
 #elif defined(__arm__)
     for (iprime=0; iprime<G;iprime+=8,j2+=8)
       *((int16x8_t *)&ulsch_harq->e[iprime]) = *((int16x8_t *)&y[j2]);
-#endif 
+#endif
+    */
+    int16_t *yp,*ep;
+    for (iprime=0,yp=&y[j2],ep=&ulsch_harq->e[0]; 
+	 iprime<G;
+	 iprime+=8,j2+=8,ep+=8,yp+=8) {
+      ep[0] = yp[0];
+      ep[1] = yp[1];
+      ep[2] = yp[2];
+      ep[3] = yp[3];
+      ep[4] = yp[4];
+      ep[5] = yp[5];
+      ep[6] = yp[6];
+      ep[7] = yp[7];
+    }
   }
-
+    
+   
   stop_meas(&eNB->ulsch_demultiplexing_stats);
 
   //  printf("after ACKNAK2 c[%d] = %p (iprime %d, G %d)\n",0,ulsch_harq->c[0],iprime,G);
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
index 399fd701ce..573a3401b0 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
@@ -814,15 +814,15 @@ schedule_ue_spec(
           if (rlc_status.bytes_in_buffer > 0) {  // There is DCCH to transmit
             LOG_D(MAC,"[eNB %d] Frame %d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n",
                   module_idP,frameP,CC_id,TBS-header_len_dcch);
-            sdu_lengths[0] += mac_rlc_data_req(
-                                module_idP,
-                                rnti,
-				module_idP,
-                                frameP,
-                                ENB_FLAG_YES,
-                                MBMS_FLAG_NO,
-                                DCCH,
-                                (char *)&dlsch_buffer[sdu_lengths[0]]);
+            sdu_lengths[0] = mac_rlc_data_req(
+					      module_idP,
+					      rnti,
+					      module_idP,
+					      frameP,
+					      ENB_FLAG_YES,
+					      MBMS_FLAG_NO,
+					      DCCH,
+					      (char *)&dlsch_buffer[0]);
 
             T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP),
               T_INT(harq_pid), T_INT(DCCH), T_INT(sdu_lengths[0]));
@@ -847,7 +847,7 @@ schedule_ue_spec(
             sdu_length_total = 0;
           }
         }
-
+	
         // check for DCCH1 and update header information (assume 2 byte sub-header)
         if (TBS-ta_len-header_len_dcch-sdu_length_total > 0 ) {
           rlc_status = mac_rlc_status_ind(
@@ -860,9 +860,10 @@ schedule_ue_spec(
                          DCCH+1,
                          (TBS-ta_len-header_len_dcch-sdu_length_total)); // transport block set size less allocations for timing advance and
           // DCCH SDU
+	  sdu_lengths[num_sdus] = 0;
 
           if (rlc_status.bytes_in_buffer > 0) {
-            LOG_D(MAC,"[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n",
+            LOG_I(MAC,"[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n",
                   module_idP,frameP,CC_id,TBS-header_len_dcch-sdu_length_total);
             sdu_lengths[num_sdus] += mac_rlc_data_req(
                                        module_idP,
@@ -872,7 +873,7 @@ schedule_ue_spec(
                                        ENB_FLAG_YES,
                                        MBMS_FLAG_NO,
                                        DCCH+1,
-                                       (char *)&dlsch_buffer[sdu_lengths[num_sdus]]);
+                                       (char *)&dlsch_buffer[sdu_length_total]);
 
             T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP),
               T_INT(harq_pid), T_INT(DCCH+1), T_INT(sdu_lengths[num_sdus]));
diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c
index 911f265b63..c30e726609 100644
--- a/targets/RT/USER/lte-enb.c
+++ b/targets/RT/USER/lte-enb.c
@@ -966,8 +966,8 @@ void rx_fh_if5(PHY_VARS_eNB *eNB,int *frame, int *subframe) {
 
   recv_IF5(eNB, &proc->timestamp_rx, *subframe, IF5_RRH_GW_UL); 
 
-  proc->frame_rx    = (proc->timestamp_rx-eNB / (fp->samples_per_tti*10))&1023;
-  proc->subframe_rx = (proc->timestamp_rx-eNB / fp->samples_per_tti)%10;
+  proc->frame_rx    = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023;
+  proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10;
   
   if (proc->first_rx == 0) {
     if (proc->subframe_rx != *subframe){
-- 
GitLab