From d71ce5a4eda1eb3ca1bed1830eaa1d75c7576a25 Mon Sep 17 00:00:00 2001
From: Michele Paffetti <michele.paffetti@eurecom.fr>
Date: Tue, 20 Jun 2017 11:18:30 +0200
Subject: [PATCH] add some comment in the code for the integration week work

---
 openair1/PHY/LTE_TRANSPORT/defs_nb_iot.h      |  3 +++
 openair1/PHY/defs_nb_iot.h                    |  2 ++
 .../SCHED/phy_procedures_lte_eNb_nb_iot.c     | 14 +++++++++----
 openair2/LAYER2/MAC/main.c                    |  4 ++--
 openair2/LAYER2/MAC/main_nb_iot.c             | 20 +++++++++----------
 openair2/RRC/LITE/L2_interface_nb_iot.c       |  9 ++++++---
 openair2/RRC/LITE/proto_nb_iot.h              |  2 +-
 7 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/openair1/PHY/LTE_TRANSPORT/defs_nb_iot.h b/openair1/PHY/LTE_TRANSPORT/defs_nb_iot.h
index bf21ed71f3..6fc3c866e4 100644
--- a/openair1/PHY/LTE_TRANSPORT/defs_nb_iot.h
+++ b/openair1/PHY/LTE_TRANSPORT/defs_nb_iot.h
@@ -62,5 +62,8 @@ typedef struct {
   DCI_ALLOC_NB_t dci_alloc[2] ;
 } DCI_PDU_NB;
 
+// to be created LTE_eNB_DLSCH_t --> is duplicated for each number of UE and then indexed in the table
+
+
 /**@}*/
 #endif
diff --git a/openair1/PHY/defs_nb_iot.h b/openair1/PHY/defs_nb_iot.h
index 7218f8ae32..18a5e0ab0c 100644
--- a/openair1/PHY/defs_nb_iot.h
+++ b/openair1/PHY/defs_nb_iot.h
@@ -307,7 +307,9 @@ typedef struct PHY_VARS_eNB_NB_s {
   eNB_proc_NB_t           proc;
   NB_DL_FRAME_PARMS   frame_parms;
 
+  //number of UE max = 1 // in fapy is udated dinamically each subframe  and is no more a table
   LTE_eNB_DLSCH_t     *dlsch[NUMBER_OF_UE_MAX][2];   // Nusers times two spatial streams
+  //how many ULSCH we keep???? should be more that 1 for sure
   LTE_eNB_ULSCH_t     *ulsch[NUMBER_OF_UE_MAX+1];      // Nusers + number of RA
   LTE_eNB_DLSCH_t     *dlsch_SI,*dlsch_ra;
   LTE_eNB_DLSCH_t     *dlsch_MCH;
diff --git a/openair1/SCHED/phy_procedures_lte_eNb_nb_iot.c b/openair1/SCHED/phy_procedures_lte_eNb_nb_iot.c
index 07bcc2d84c..4579ff54f3 100644
--- a/openair1/SCHED/phy_procedures_lte_eNb_nb_iot.c
+++ b/openair1/SCHED/phy_procedures_lte_eNb_nb_iot.c
@@ -617,11 +617,12 @@ void NB_phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
     } 
 
 
-  //ignore the PMCH part only do the generate PSS/SSS, note: Seperate MIB from here
-  NB_common_signal_procedures(eNB,proc);
+
 
   while(!oai_exit)
     {
+	  //ignore the PMCH part only do the generate PSS/SSS, note: Seperate MIB from here
+	  NB_common_signal_procedures(eNB,proc);
 
         //Not test yet , mutex_l2, cond_l2, instance_cnt_l2
         if(wait_on_condition(&proc->mutex_l2,&proc->cond_l2,&proc->instance_cnt_l2,"eNB_L2_thread") < 0) 
@@ -660,11 +661,14 @@ void NB_phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
       
       if (Sched_Rsp->NB_DL.NB_DCI.DL_DCI.npdcch_pdu_rel13.rnti<= P_RNTI) 
         {
+    	  //is not system iformation but cound be paging
+    	  //in any case we generate dlsch for not system information
           UE_id = find_ue((int16_t)Sched_Rsp->NB_DL.NB_DCI.DL_DCI.npdcch_pdu_rel13.rnti,eNB);
         }
       else 
         UE_id=0;
     
+      //inside we hve nFAPI to OAI parameters
       NB_generate_eNB_dlsch_params(eNB,proc,Sched_Rsp,UE_id);
       
       /* Apply physicalConfigDedicated if needed, don't know if needed in NB-IoT or not
@@ -682,11 +686,13 @@ void NB_phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
       /*If we have DCI to generate do it now TODO : have a generate dci top for NB_IoT */      
       //NB_generate_dci_top();
 
+
+      // what should be figurate this week
       if(Sched_Rsp->NB_DL.NB_DLSCH.NPDSCH_pdu.segments)
         {
-            /*TODO: MPDSCH procedures for NB-IoT*/
+            /*TODO: NPDSCH procedures for NB-IoT*/
             //npdsch_procedures();
         }
 
     }
-}
\ No newline at end of file
+}
diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c
index abf12cb6cf..a400b3a16b 100644
--- a/openair2/LAYER2/MAC/main.c
+++ b/openair2/LAYER2/MAC/main.c
@@ -400,11 +400,11 @@ int mac_init_global_param(void)
   //  Mac_rlc_xface->dl_phy_sync_success=dl_phy_sync_success;
 
 
-#ifndef NB_IOT
+
   LOG_I(MAC,"[MAIN] RLC interface setup and init\n");
   rrc_init_global_param();
   //MP: otherwise we call the initialization of the RRC NB-IoT module (see mac_init_global_param_NB)
-#endif
+
 
 #ifdef USER_MODE
   pdcp_layer_init ();
diff --git a/openair2/LAYER2/MAC/main_nb_iot.c b/openair2/LAYER2/MAC/main_nb_iot.c
index cab3c6181b..db6c2b4184 100644
--- a/openair2/LAYER2/MAC/main_nb_iot.c
+++ b/openair2/LAYER2/MAC/main_nb_iot.c
@@ -42,9 +42,9 @@ int mac_init_global_param_NB(void)
 //  Mac_rlc_xface = NULL;
 //  LOG_I(MAC,"[MAIN] CALLING RLC_MODULE_INIT...\n");
 //
-//  if (rlc_module_init()!=0) {
-//    return(-1);
-//  }
+  if (rlc_module_init()!=0) {
+    return(-1);
+ }
 //
 //  LOG_I(MAC,"[MAIN] RLC_MODULE_INIT OK, malloc16 for mac_rlc_xface...\n");
 //
@@ -69,12 +69,12 @@ int mac_init_global_param_NB(void)
   rrc_init_global_param_NB();
 
 
-//  LOG_I(MAC,"[MAIN] PDCP layer init\n");
-//#ifdef USER_MODE
-//  pdcp_layer_init ();
-//#else
-//  pdcp_module_init ();
-//#endif
+  LOG_I(MAC,"[MAIN] PDCP layer init\n");
+#ifdef USER_MODE
+  pdcp_layer_init ();
+#else
+  pdcp_module_init ();
+#endif
 //
 //  LOG_I(MAC,"[MAIN] Init Global Param Done\n");
 
@@ -135,7 +135,7 @@ int mac_top_init_NB()
   if (Is_rrc_nb_iot_registered == 1) {
     LOG_I(MAC,"[MAIN] calling RRC NB-IoT\n");
 #ifndef CELLULAR //nothing to be done yet for cellular
-    openair_rrc_top_init_NB();
+    openair_rrc_top_init_eNB_NB();
 #endif
   } else {
     LOG_I(MAC,"[MAIN] Running without an RRC\n");
diff --git a/openair2/RRC/LITE/L2_interface_nb_iot.c b/openair2/RRC/LITE/L2_interface_nb_iot.c
index a0654e99e8..2e118cceb9 100644
--- a/openair2/RRC/LITE/L2_interface_nb_iot.c
+++ b/openair2/RRC/LITE/L2_interface_nb_iot.c
@@ -181,6 +181,8 @@ int NB_rrc_mac_config_req_eNB(
 
    //mac_top_init_eNB(); //TODO MP:  to be included in the MAC/main.c
 
+	  ///to review with the Raymond implementation
+
     eNB_mac_inst_NB[Mod_idP].common_channels[CC_idP].mib_NB           = mib_NB;
     eNB_mac_inst_NB[Mod_idP].common_channels[CC_idP].physCellId     = physCellId;
     eNB_mac_inst_NB[Mod_idP].common_channels[CC_idP].p_eNB          = p_eNB;
@@ -208,14 +210,15 @@ int NB_rrc_mac_config_req_eNB(
 
     config_INFO->get_MIB = 1;
     config_INFO->rnti = rntiP;
-    config_INFO->frequency_band_indicator = (uint8_t)eutra_band;
+    config_INFO->frequency_band_indicator = (uint8_t)eutra_band; // guarda raimon
     config_INFO->sch_config.physical_cell_id.value = physCellId;
     config_INFO->subframe_config.dl_cyclic_prefix_type.value = Ncp;
     config_INFO->subframe_config.ul_cyclic_prefix_type.value = Ncp_UL;
     config_INFO->rf_config.tx_antenna_ports.value = p_eNB;
     config_INFO->rf_config.rx_antenna_ports.value = p_rx_eNB;
-    config_INFO->dl_CarrierFreq = dl_CarrierFreq;
-    config_INFO->ul_CarrierFreq = ul_CarrierFreq;
+    config_INFO->dl_CarrierFreq = dl_CarrierFreq; //guarda raymond is in rf_config
+    config_INFO->ul_CarrierFreq = ul_CarrierFreq; //guarda raymond
+
 
     switch (mib_NB->message.operationModeInfo_r13.present)
     {
diff --git a/openair2/RRC/LITE/proto_nb_iot.h b/openair2/RRC/LITE/proto_nb_iot.h
index 404e9f559c..d9baecd3ec 100644
--- a/openair2/RRC/LITE/proto_nb_iot.h
+++ b/openair2/RRC/LITE/proto_nb_iot.h
@@ -47,7 +47,7 @@ void rrc_config_buffer_NB(SRB_INFO_NB *srb_info, uint8_t Lchan_type, uint8_t Rol
 
 int L3_xface_init_NB(void);
 
-void openair_rrc_top_init_NB( char *uecap_xer);
+void openair_rrc_top_init_eNB_NB(void);
 
 //void rrc_top_cleanup(void); -->seems not to be used
 
-- 
2.26.2