From 10e3a299bee587dc8da15fa333c09849ae5cde9c Mon Sep 17 00:00:00 2001
From: Ahmed Hussein <husseiad@iis.fraunhofer.de>
Date: Tue, 14 May 2019 17:14:12 +0200
Subject: [PATCH] Restructuring "nr_slot_fep_ul"

- Now it takes input and output pointers instead of gNB struct
---
 openair1/PHY/MODULATION/nr_modulation.h   |  8 ++++++--
 openair1/PHY/MODULATION/slot_fep_nr.c     | 21 ++++++++++-----------
 openair1/SCHED_NR/phy_procedures_nr_gNB.c | 12 +++++++++++-
 3 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/openair1/PHY/MODULATION/nr_modulation.h b/openair1/PHY/MODULATION/nr_modulation.h
index d807244ba29..249a92e8e30 100644
--- a/openair1/PHY/MODULATION/nr_modulation.h
+++ b/openair1/PHY/MODULATION/nr_modulation.h
@@ -55,14 +55,18 @@ void nr_layer_mapping(int16_t **mod_symbs,
 
 /*!
 \brief This function implements the OFDM front end processor on reception (FEP)
-\param phy_vars_ue Pointer to PHY variables
+\param frame_parms Pointer to frame parameters
+\param rxdata Pointer to input data in time domain
+\param rxdataF Pointer to output data in frequency domain
 \param symbol symbol within slot (0..12/14)
 \param Ns Slot number (0..19)
 \param sample_offset offset within rxdata (points to beginning of subframe)
 \param no_prefix if 1 prefix is removed by HW
 */
 
-int nr_slot_fep_ul(PHY_VARS_gNB *phy_vars_gNB,
+int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms,
+                   int32_t *rxdata,
+                   int32_t *rxdataF,
                    unsigned char symbol,
                    unsigned char Ns,
                    int sample_offset,
diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c
index 8494b2e379c..b93f6be2502 100644
--- a/openair1/PHY/MODULATION/slot_fep_nr.c
+++ b/openair1/PHY/MODULATION/slot_fep_nr.c
@@ -200,17 +200,17 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
 }
 
 
-int nr_slot_fep_ul(PHY_VARS_gNB *gNB,
+int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms,
+                   int32_t *rxdata,
+                   int32_t *rxdataF,
                    unsigned char symbol,
                    unsigned char Ns,
                    int sample_offset,
                    int no_prefix)
 {
-  unsigned char aa;
   uint32_t slot_offset;
   uint32_t rxdata_offset;
 
-  NR_DL_FRAME_PARMS *frame_parms  = &gNB->frame_parms;
   unsigned int nb_prefix_samples  = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
   unsigned int nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0);
   
@@ -256,15 +256,14 @@ int nr_slot_fep_ul(PHY_VARS_gNB *gNB,
   
   slot_offset   = Ns * frame_parms->samples_per_slot;
 
-  for (aa = 0; aa < frame_parms->nb_antennas_rx; aa++) {
-    if(symbol == 0)
-      rxdata_offset = slot_offset + nb_prefix_samples0 - SOFFSET;
-    else
-      rxdata_offset = slot_offset + nb_prefix_samples0 + (symbol * (frame_parms->ofdm_symbol_size + nb_prefix_samples)) - SOFFSET;
+  
+  if(symbol == 0)
+    rxdata_offset = slot_offset + nb_prefix_samples0 - SOFFSET;
+  else
+    rxdata_offset = slot_offset + nb_prefix_samples0 + (symbol * (frame_parms->ofdm_symbol_size + nb_prefix_samples)) - SOFFSET;
 
-    dft((int16_t *)&gNB->common_vars.rxdata[aa][rxdata_offset],
-        (int16_t *)&gNB->common_vars.rxdataF[aa][symbol * frame_parms->ofdm_symbol_size], 1);
-  }
+  dft((int16_t *)&rxdata[rxdata_offset],
+       (int16_t *)&rxdataF[symbol * frame_parms->ofdm_symbol_size], 1);
 
   return(0);
 }
diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c
index e982f3c9643..ce0d812309e 100644
--- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c
+++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c
@@ -239,9 +239,19 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc, int UE_id,
 void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc) {
 
   uint8_t symbol;
+  unsigned char aa;
 
   for(symbol = 0; symbol < NR_SYMBOLS_PER_SLOT; symbol++) {
-    nr_slot_fep_ul(gNB, symbol, proc->slot_rx, 0, 0);
+    // nr_slot_fep_ul(gNB, symbol, proc->slot_rx, 0, 0);
+    for (aa = 0; aa < gNB->frame_parms.nb_antennas_rx; aa++) {
+      nr_slot_fep_ul(&gNB->frame_parms,
+                     gNB->common_vars.rxdata[aa],
+                     gNB->common_vars.rxdataF[aa],
+                     symbol,
+                     proc->slot_rx,
+                     0,
+                     0);
+    }
   }
 
 }
-- 
GitLab