From 1ab1fde7b83c4b57582cd43c1a34672a8fa17d65 Mon Sep 17 00:00:00 2001
From: francescomani <email@francescomani.it>
Date: Fri, 11 Mar 2022 14:00:30 +0100
Subject: [PATCH] fix for fdd and other warnings

---
 executables/nr-softmodem.c          | 2 +-
 openair2/LAYER2/NR_MAC_gNB/config.c | 8 ++------
 openair2/RRC/NR/MESSAGES/asn1_msg.c | 1 +
 openair2/RRC/NR/nr_rrc_config.c     | 8 ++------
 4 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c
index 2fe6c86b41..1c75d9a155 100644
--- a/executables/nr-softmodem.c
+++ b/executables/nr-softmodem.c
@@ -741,7 +741,7 @@ int main( int argc, char **argv ) {
       RC.ru[ru_id]->rf_map.card=0;
       RC.ru[ru_id]->rf_map.chain=CC_id+chain_offset;
       if (ru_id==0) sl_ahead = RC.ru[ru_id]->sl_ahead;	
-      else AssertFatal(RC.ru[ru_id]->sl_ahead != RC.ru[0]->sl_ahead,"RU %d has different sl_ahead %d than RU 0 %d\n",RC.ru[ru_id]->sl_ahead,RC.ru[0]->sl_ahead);
+      else AssertFatal(RC.ru[ru_id]->sl_ahead != RC.ru[0]->sl_ahead,"RU %d has different sl_ahead %d than RU 0 %d\n",ru_id,RC.ru[ru_id]->sl_ahead,RC.ru[0]->sl_ahead);
     }
     
   }
diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c
index aaa97fea87..943bb04cb7 100644
--- a/openair2/LAYER2/NR_MAC_gNB/config.c
+++ b/openair2/LAYER2/NR_MAC_gNB/config.c
@@ -446,11 +446,8 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
     AssertFatal(RC.nrmac[Mod_idP]->UL_tti_req_ahead[0],
                 "could not allocate memory for RC.nrmac[]->UL_tti_req_ahead[]\n");
     /* fill in slot/frame numbers: slot is fixed, frame will be updated by scheduler
-       extern sf_ahead is initialized in ru_thread but that function is not executed yet here*/
-    const uint16_t sf_ahead = (uint16_t) ceil((float)6/(0x01<<(*scc->ssbSubcarrierSpacing)));
-    const uint16_t sl_ahead = sf_ahead * (0x01<<(*scc->ssbSubcarrierSpacing));
-    /* consider that scheduler runs sl_ahead: the first sl_ahead slots are
-     * already "in the past" and thus we put frame 1 instead of 0!*/
+     * consider that scheduler runs sl_ahead: the first sl_ahead slots are
+     * already "in the past" and thus we put frame 1 instead of 0! */
     for (int i = 0; i < n; ++i) {
       nfapi_nr_ul_tti_request_t *req = &RC.nrmac[Mod_idP]->UL_tti_req_ahead[0][i];
       req->SFN = i < (RC.nrmac[Mod_idP]->if_inst->sl_ahead-1);
@@ -667,7 +664,6 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
   }
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT);
   
-    
   return(0);
 
 }// END rrc_mac_config_req_gNB
diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c
index 1bbecb3328..1830a3ca3a 100755
--- a/openair2/RRC/NR/MESSAGES/asn1_msg.c
+++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c
@@ -41,6 +41,7 @@
 #include <per_encoder.h>
 #include <nr/nr_common.h>
 
+#include "LAYER2/nr_rlc/nr_rlc_oai_api.h"
 #include "asn1_msg.h"
 #include "../nr_rrc_proto.h"
 #include "RRC/NR/nr_rrc_extern.h"
diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c
index 87543da5f9..2dbb8c93d5 100644
--- a/openair2/RRC/NR/nr_rrc_config.c
+++ b/openair2/RRC/NR/nr_rrc_config.c
@@ -110,13 +110,10 @@ void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay){
   //TODO change to accomodate for SRS
 
   lte_frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing);
-  int temp_min_delay; 
+  int temp_min_delay = 6; // k2 = 2 or 3 won'r work as well as higher values
   if(frame_type==TDD && scc->tdd_UL_DL_ConfigurationCommon) {
-  
+
     switch (scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity) {
-      default:
-        temp_min_delay = 6;
-        break;
       case NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms2p5:  // 30kHz SCS
       case NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms2:    // 60kHz SCS
       case NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms1p25: // 60kHz SCS
@@ -128,7 +125,6 @@ void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay){
     }
   }
 
-
   int k2 = (min_fb_delay<temp_min_delay)?temp_min_delay:min_fb_delay;
 
   uint8_t DELTA[4]= {2,3,4,6}; // Delta parameter for Msg3
-- 
2.26.2