From 5131449160444af34b55015e57c9534c865ab66a Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Tue, 4 Sep 2018 12:36:42 +0200
Subject: [PATCH] bugfix: add handling of DFT 768 everywhere it's needed

In the eNB it's not really used for the moment because there
is a limitation to uplink scheduling. In
openair2/LAYER2/MAC/eNB_scheduler_ulsch.c we have:

            while (((rb_table[rb_table_index] > (N_RB_UL - 1 - first_rb[CC_id]))
                    || (rb_table[rb_table_index] > 45))

That limits uplink scheduling to at most 44 RBs. The 768 case is for
64 RBs.
---
 .../PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c |  2 +-
 openair1/PHY/LTE_REFSIG/lte_ul_ref.c               | 14 +++++++-------
 openair1/PHY/LTE_TRANSPORT/transport_extern.h      |  8 ++++----
 openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c    |  6 ++++++
 openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c     |  2 +-
 openair1/PHY/LTE_UE_TRANSPORT/srs_modulation.c     |  2 +-
 openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c   |  6 ++++++
 openair1/PHY/TOOLS/tools_defs.h                    |  1 +
 openair1/SIMULATION/LTE_PHY/unitary_defs.h         |  4 ++--
 9 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
index e5b28ff2e3..a8d73cfdea 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c
@@ -91,7 +91,7 @@ int32_t temp_in_ifft_0[2048*2] __attribute__((aligned(32)));
                   eNB->ulsch[UE_id]->harq_processes[harq_pid]->n_DMRS2 +
                   frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[(subframe<<1)+Ns]) % 12;
 
-  Msc_idx_ptr = (uint16_t*) bsearch(&Msc_RS, dftsizes, 33, sizeof(uint16_t), compareints);
+  Msc_idx_ptr = (uint16_t*) bsearch(&Msc_RS, dftsizes, 34, sizeof(uint16_t), compareints);
 
   if (Msc_idx_ptr)
     Msc_RS_idx = Msc_idx_ptr - dftsizes;
diff --git a/openair1/PHY/LTE_REFSIG/lte_ul_ref.c b/openair1/PHY/LTE_REFSIG/lte_ul_ref.c
index 01b27205c2..ee7619c23c 100644
--- a/openair1/PHY/LTE_REFSIG/lte_ul_ref.c
+++ b/openair1/PHY/LTE_REFSIG/lte_ul_ref.c
@@ -27,13 +27,13 @@
 #include "lte_refsig.h"
 #include "PHY/defs_eNB.h"
 
-uint16_t dftsizes[33] = {12,24,36,48,60,72,96,108,120,144,180,192,216,240,288,300,324,360,384,432,480,540,576,600,648,720,864,900,960,972,1080,1152,1200};
+uint16_t dftsizes[34] = {12,24,36,48,60,72,96,108,120,144,180,192,216,240,288,300,324,360,384,432,480,540,576,600,648,720,768,864,900,960,972,1080,1152,1200};
 
-uint16_t ref_primes[33] = {11,23,31,47,59,71,89,107,113,139,179,191,211,239,283,293,317,359,383,431,479,523,571,599,647,719,863,887,953,971,1069,1151,1193};
+uint16_t ref_primes[34] = {11,23,31,47,59,71,89,107,113,139,179,191,211,239,283,293,317,359,383,431,479,523,571,599,647,719,761,863,887,953,971,1069,1151,1193};
 
 
-int16_t *ul_ref_sigs[30][2][33];
-int16_t *ul_ref_sigs_rx[30][2][33]; //these contain the sequences in repeated format and quantized to QPSK ifdef IFFT_FPGA
+int16_t *ul_ref_sigs[30][2][34];
+int16_t *ul_ref_sigs_rx[30][2][34]; //these contain the sequences in repeated format and quantized to QPSK ifdef IFFT_FPGA
 
 /* 36.211 table 5.5.1.2-1 */
 char ref12[360] = {-1,1,3,-3,3,3,1,1,3,1,-3,3,1,1,3,3,3,-1,1,-3,-3,1,-3,3,1,1,-3,-3,-3,-1,-3,-3,1,-3,1,-1,-1,1,1,1,1,-1,-3,-3,1,-3,3,-1,-1,3,1,-1,1,-1,-3,-1,1,-1,1,3,1,-3,3,-1,-1,1,1,-1,-1,3,-3,1,-1,3,-3,-3,-3,3,1,-1,3,3,-3,1,-3,-1,-1,-1,1,-3,3,-1,1,-3,3,1,1,-3,3,1,-1,-1,-1,1,1,3,-1,1,1,-3,-1,3,3,-1,-3,1,1,1,1,1,-1,3,-1,1,1,-3,-3,-1,-3,-3,3,-1,3,1,-1,-1,3,3,-3,1,3,1,3,3,1,-3,1,1,-3,1,1,1,-3,-3,-3,1,3,3,-3,3,-3,1,1,3,-1,-3,3,3,-3,1,-1,-3,-1,3,1,3,3,3,-1,1,3,-1,1,-3,-1,-1,1,1,3,1,-1,-3,1,3,1,-1,1,3,3,3,-1,-1,3,-1,-3,1,1,3,-3,3,-3,-3,3,1,3,-1,-3,3,1,1,-3,1,-3,-3,-1,-1,1,-3,-1,3,1,3,1,-1,-1,3,-3,-1,-3,-1,-1,-3,1,1,1,1,3,1,-1,1,-3,-1,-1,3,-1,1,-3,-3,-3,-3,-3,1,-1,-3,1,1,-3,-3,-3,-3,-1,3,-3,1,-3,3,1,1,-1,-3,-1,-3,1,-1,1,3,-1,1,1,1,3,1,3,3,-1,1,-1,-3,-3,1,1,-3,3,3,1,3,3,1,-3,-1,-1,3,1,3,-3,-3,3,-3,1,-1,-1,3,-1,-3,-3,-1,-3,-1,-3,3,1,-1,1,3,-3,-3,-1,3,-3,3,-1,3,3,-3,3,3,-1,-1,3,-3,-3,-1,-1,-3,-1,3,-3,3,1,-1};
@@ -49,7 +49,7 @@ void generate_ul_ref_sigs(void)
   unsigned int u,v,Msc_RS,q,m,n;
 
   // These are the Zadoff-Chu sequences (for RB 3-100)
-  for (Msc_RS=2; Msc_RS<33; Msc_RS++) {
+  for (Msc_RS=2; Msc_RS<34; Msc_RS++) {
     for (u=0; u<30; u++) {
       for (v=0; v<2; v++) {
         qbar = ref_primes[Msc_RS] * (u+1)/(double)31;
@@ -119,7 +119,7 @@ void generate_ul_ref_sigs_rx(void)
   unsigned int u,v,Msc_RS,q,m,n;
 
   // These are the complex conjugated Zadoff-Chu sequences quantized to QPSK stored in repeated format (for RB 3-100)
-  for (Msc_RS=2; Msc_RS<33; Msc_RS++) {
+  for (Msc_RS=2; Msc_RS<34; Msc_RS++) {
     for (u=0; u<30; u++) {
       for (v=0; v<2; v++) {
         qbar = ref_primes[Msc_RS] * (u+1)/(double)31;
@@ -186,7 +186,7 @@ void free_ul_ref_sigs(void)
 
   unsigned int u,v,Msc_RS;
 
-  for (Msc_RS=0; Msc_RS<33; Msc_RS++) {
+  for (Msc_RS=0; Msc_RS<34; Msc_RS++) {
     for (u=0; u<30; u++) {
       for (v=0; v<2; v++) {
         if (ul_ref_sigs[u][v][Msc_RS]) {
diff --git a/openair1/PHY/LTE_TRANSPORT/transport_extern.h b/openair1/PHY/LTE_TRANSPORT/transport_extern.h
index 6a9fa49405..1ddf5ac040 100644
--- a/openair1/PHY/LTE_TRANSPORT/transport_extern.h
+++ b/openair1/PHY/LTE_TRANSPORT/transport_extern.h
@@ -25,10 +25,10 @@ extern char lte_cqi_snr_dB[15];
 extern short conjugate[8],conjugate2[8];
 extern short minus_one[8];
 extern short minus_one[8];
-extern short *ul_ref_sigs[30][2][33];
-extern short *ul_ref_sigs_rx[30][2][33];
-extern unsigned short dftsizes[33];
-extern unsigned short ref_primes[33];
+extern short *ul_ref_sigs[30][2][34];
+extern short *ul_ref_sigs_rx[30][2][34];
+extern unsigned short dftsizes[34];
+extern unsigned short ref_primes[34];
 
 extern int qam64_table[8],qam16_table[4],qpsk_table[2];
 
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
index adb0d1576f..61076f2aae 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
@@ -335,6 +335,12 @@ void lte_idft(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *z, uint16_t Msc_PUSCH)
     dft720((int16_t*)idft_in2,(int16_t*)idft_out2,1);
     break;
 
+  case 768:
+    dft768((int16_t*)idft_in0,(int16_t*)idft_out0,1);
+    dft768((int16_t*)idft_in1,(int16_t*)idft_out1,1);
+    dft768((int16_t*)idft_in2,(int16_t*)idft_out2,1);
+    break;
+
   case 864:
     dft864((int16_t*)idft_in0,(int16_t*)idft_out0,1);
     dft864((int16_t*)idft_in1,(int16_t*)idft_out1,1);
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c b/openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c
index 96ff82ba16..1c49cde394 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c
@@ -83,7 +83,7 @@ int generate_drs_pusch(PHY_VARS_UE *ue,
   //        cyclic_shift1 = 0;
   Msc_RS = 12*nb_rb;
 
-  Msc_idx_ptr = (uint16_t*) bsearch(&Msc_RS, dftsizes, 33, sizeof(uint16_t), compareints);
+  Msc_idx_ptr = (uint16_t*) bsearch(&Msc_RS, dftsizes, 34, sizeof(uint16_t), compareints);
 
   if (Msc_idx_ptr)
     Msc_RS_idx = Msc_idx_ptr - dftsizes;
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/srs_modulation.c b/openair1/PHY/LTE_UE_TRANSPORT/srs_modulation.c
index 8bb2299b7c..e6960273c7 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/srs_modulation.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/srs_modulation.c
@@ -181,7 +181,7 @@ int32_t generate_srs(LTE_DL_FRAME_PARMS *frame_parms,
     return(-1);
   }
 
-  Msc_idx_ptr = (uint16_t*) bsearch((uint16_t*) &Msc_RS, (uint16_t*) dftsizes, 33, sizeof(uint16_t), compareints);
+  Msc_idx_ptr = (uint16_t*) bsearch((uint16_t*) &Msc_RS, (uint16_t*) dftsizes, 34, sizeof(uint16_t), compareints);
 
   if (Msc_idx_ptr)
     Msc_RS_idx = Msc_idx_ptr - dftsizes;
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c
index 1281f815f8..a9878b4eae 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c
@@ -287,6 +287,12 @@ void dft_lte(int32_t *z,int32_t *d, int32_t Msc_PUSCH, uint8_t Nsymb)
     dft720((int16_t*)dft_in2,(int16_t*)dft_out2,1);
     break;
 
+  case 768:
+    dft768((int16_t*)dft_in0,(int16_t*)dft_out0,1);
+    dft768((int16_t*)dft_in1,(int16_t*)dft_out1,1);
+    dft768((int16_t*)dft_in2,(int16_t*)dft_out2,1);
+    break;
+
   case 864:
     dft864((int16_t*)dft_in0,(int16_t*)dft_out0,1);
     dft864((int16_t*)dft_in1,(int16_t*)dft_out1,1);
diff --git a/openair1/PHY/TOOLS/tools_defs.h b/openair1/PHY/TOOLS/tools_defs.h
index a5e8d49eb7..6b7e0f5595 100644
--- a/openair1/PHY/TOOLS/tools_defs.h
+++ b/openair1/PHY/TOOLS/tools_defs.h
@@ -375,6 +375,7 @@ void dft576(int16_t *x,int16_t *y,uint8_t scale_flag);
 void dft600(int16_t *x,int16_t *y,uint8_t scale_flag);
 void dft648(int16_t *x,int16_t *y,uint8_t scale_flag);
 void dft720(int16_t *x,int16_t *y,uint8_t scale_flag);
+void dft768(int16_t *x,int16_t *y,uint8_t scale_flag);
 void dft864(int16_t *x,int16_t *y,uint8_t scale_flag);
 void dft900(int16_t *x,int16_t *y,uint8_t scale_flag);
 void dft960(int16_t *x,int16_t *y,uint8_t scale_flag);
diff --git a/openair1/SIMULATION/LTE_PHY/unitary_defs.h b/openair1/SIMULATION/LTE_PHY/unitary_defs.h
index 133656a562..27bd9794f2 100644
--- a/openair1/SIMULATION/LTE_PHY/unitary_defs.h
+++ b/openair1/SIMULATION/LTE_PHY/unitary_defs.h
@@ -27,5 +27,5 @@ void exit_fun(const char *s) { exit(-1); }
 extern unsigned int dlsch_tbs25[27][25],TBStable[27][110];
 extern unsigned char offset_mumimo_llr_drange_fix;
 
-extern unsigned short dftsizes[33];
-extern short *ul_ref_sigs[30][2][33];
+extern unsigned short dftsizes[34];
+extern short *ul_ref_sigs[30][2][34];
-- 
GitLab