From c42a593292d8a219deeeb4f7a66fd90f198d02a8 Mon Sep 17 00:00:00 2001
From: David Price <davpric2@cisco.com>
Date: Tue, 14 Nov 2017 14:44:25 +0000
Subject: [PATCH] Works in monolithic mode and nFAPI mode

---
 nfapi/nfapi_pnf.c                             |  4 ++
 openair1/SCHED/phy_procedures_lte_eNb.c       |  2 +-
 openair2/ENB_APP/enb_config.c                 | 16 +++-----
 openair2/LAYER2/MAC/config.c                  | 33 ++++++++++++----
 openair2/LAYER2/MAC/eNB_scheduler.c           |  4 +-
 openair2/LAYER2/MAC/eNB_scheduler_RA.c        | 33 ++++++++--------
 .../LAYER2/MAC/eNB_scheduler_primitives.c     |  2 +-
 openair2/LAYER2/MAC/eNB_scheduler_ulsch.c     |  2 +-
 openair2/PHY_INTERFACE/IF_Module.c            |  2 +-
 openair2/RRC/LITE/rrc_eNB.c                   |  4 +-
 .../CONF/enb.band7.tm1.50PRB.usrpb210.conf    | 38 ++++++++++---------
 .../CONF/oaiL1.nfapi.usrpb210.conf            |  4 +-
 .../CONF/rcc.band7.tm1.50PRB.nfapi.conf       | 36 +++++++++---------
 targets/RT/USER/lte-enb.c                     |  2 +-
 targets/RT/USER/lte-softmodem.c               |  6 +++
 15 files changed, 107 insertions(+), 81 deletions(-)

diff --git a/nfapi/nfapi_pnf.c b/nfapi/nfapi_pnf.c
index bb70eb0fc88..e1a62b0c07f 100644
--- a/nfapi/nfapi_pnf.c
+++ b/nfapi/nfapi_pnf.c
@@ -27,6 +27,8 @@ extern RAN_CONTEXT_t RC;
 
 #define NUM_P5_PHY 2
 
+#define _GNU_SOURCE
+
 extern void phy_init_RU(RU_t*);
 extern int config_sync_var;
 
@@ -1730,6 +1732,8 @@ void* pnf_start_thread(void* ptr)
 
 void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port)
 {
+  printf("%s() PNF\n\n\n\n\n\n", __FUNCTION__);
+
   nfapi_mode = 1;  // PNF!
 
   nfapi_pnf_config_t* config = nfapi_pnf_config_create();
diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c
index 0c2831f4675..9d9c84706b5 100644
--- a/openair1/SCHED/phy_procedures_lte_eNb.c
+++ b/openair1/SCHED/phy_procedures_lte_eNb.c
@@ -274,7 +274,7 @@ void pdsch_procedures(PHY_VARS_eNB *eNB,
   if (1){
   //if (dlsch->rnti == 0x02) {//frame < 200) {
 
-    LOG_I(PHY,
+    LOG_D(PHY,
 	  "[eNB %"PRIu8"][PDSCH %"PRIx16"/%"PRIu8"] Frame %d, subframe %d: Generating PDSCH/DLSCH with input size = %"PRIu16", pdsch_start %d, G %d, nb_rb %"PRIu16", rb0 %x, rb1 %x, TBS %"PRIu16", pmi_alloc %"PRIx64", rv %"PRIu8" (round %"PRIu8")\n",
 	  eNB->Mod_id, dlsch->rnti,harq_pid,
 	  frame, subframe, input_buffer_length, dlsch_harq->pdsch_start,
diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index d34d6b36f14..3ee1196ff68 100644
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -50,6 +50,7 @@
 #include "sctp_default_values.h"
 #include "SystemInformationBlockType2.h"
 #include "LAYER2/MAC/extern.h"
+#include "LAYER2/MAC/proto.h"
 #include "PHY/extern.h"
 #include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
 #include "nfapi_vnf.h"
@@ -58,10 +59,7 @@
 #include "enb_paramdef.h"
 #include "common/config/config_userapi.h"
 
-
-int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc);
-int RCconfig_S1(MessageDef *msg_p, uint32_t i);
-
+extern uint16_t sf_ahead;
 
 static int enb_check_band_frequencies(char* lib_config_file_name_pP,
                                       int ind,
@@ -104,10 +102,6 @@ static int enb_check_band_frequencies(char* lib_config_file_name_pP,
   return errors;
 }
 
-extern void mac_top_init_eNB(void );
-extern uint8_t  nfapi_mode;
-
-
 
 /* --------------------------------------------------------*/
 /* from here function to use configuration module          */
@@ -277,6 +271,7 @@ void RCconfig_L1(void) {
 
       if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) {
 
+        sf_ahead = 4; // Need 4 subframe gap between RX and TX
       }
       else if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) {
         RC.eNB[j][0]->eth_params_n.local_if_name            = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_IF_NAME_IDX].strptr));
@@ -288,7 +283,7 @@ void RCconfig_L1(void) {
 	RC.eNB[j][0]->eth_params_n.remote_portd             = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr);
 	RC.eNB[j][0]->eth_params_n.transp_preference        = ETH_UDP_MODE;
 
-        nfapi_mode = 1;
+        sf_ahead = 2; // Cannot cope with 4 subframes betweem RX and TX - set it to 2
 
         RC.nb_macrlc_inst = 1;  // This is used by mac_top_init_eNB()
 
@@ -304,7 +299,6 @@ void RCconfig_L1(void) {
 
         mac_top_init_eNB();
 
-
         configure_nfapi_pnf(RC.eNB[j][0]->eth_params_n.remote_addr, RC.eNB[j][0]->eth_params_n.remote_portc, RC.eNB[j][0]->eth_params_n.my_addr, RC.eNB[j][0]->eth_params_n.my_portd, RC.eNB[j][0]->eth_params_n     .remote_portd);
       }
       else { // other midhaul
@@ -385,7 +379,7 @@ void RCconfig_macrlc() {
 	RC.mac[j]->eth_params_s.remote_portd             = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_PORTD_IDX].iptr);
 	RC.mac[j]->eth_params_s.transp_preference        = ETH_UDP_MODE;
 
-        nfapi_mode = 2;
+        sf_ahead = 2; // Cannot cope with 4 subframes betweem RX and TX - set it to 2
 
         printf("**************** vnf_port:%d\n", RC.mac[j]->eth_params_s.my_portc);
         configure_nfapi_vnf(RC.mac[j]->eth_params_s.my_addr, RC.mac[j]->eth_params_s.my_portc);
diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c
index 82bc7a8c29d..3245236720f 100644
--- a/openair2/LAYER2/MAC/config.c
+++ b/openair2/LAYER2/MAC/config.c
@@ -63,6 +63,8 @@ extern void mac_top_init_eNB(void);
 extern void mac_init_cell_params(int Mod_idP,int CC_idP);
 extern void phy_reset_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
 
+extern uint8_t nfapi_mode;
+
 /* sec 5.9, 36.321: MAC Reset Procedure */
 void ue_mac_reset(module_id_t module_idP,uint8_t eNB_index)
 {
@@ -748,15 +750,20 @@ int rrc_mac_config_req_eNB(module_id_t                      Mod_idP,
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN);
 
-  LOG_D(MAC, "RC.mac:%p mib:%p\n", RC.mac, mib);
+  LOG_E(MAC, "RC.mac:%p mib:%p\n", RC.mac, mib);
 
   if (RC.mac == NULL) {
+    LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
+
     l2_init_eNB();
 
+    LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
     mac_top_init_eNB();
+    LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
   }
 
   if (mib!=NULL) {
+    LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
       RC.mac[Mod_idP]->common_channels[CC_idP].mib             = mib;
       RC.mac[Mod_idP]->common_channels[CC_idP].physCellId      = physCellId;
       RC.mac[Mod_idP]->common_channels[CC_idP].p_eNB           = p_eNB;
@@ -906,6 +913,7 @@ int rrc_mac_config_req_eNB(module_id_t                      Mod_idP,
     }
   } 
 
+    LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
   if (pmch_InfoList != NULL) {
 
     //    LOG_I(MAC,"DUY: lcid when entering rrc_mac config_req is %02d\n",(pmch_InfoList->list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9));
@@ -930,21 +938,30 @@ int rrc_mac_config_req_eNB(module_id_t                      Mod_idP,
 
 #endif
 
+  LOG_E(MAC, "%s() %s:%d RC.mac[Mod_idP]->if_inst->PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.mac[Mod_idP]->if_inst->PHY_config_req);
 
-  if (RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL)
+  // if in nFAPI mode 
+  if (
+      (nfapi_mode == 1 || nfapi_mode == 2) &&
+      (RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL)
+    )
   {
     while(RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL) {
       // DJP AssertFatal(RC.mac[Mod_idP]->if_inst->PHY_config_req != NULL,"if_inst->phy_config_request is null\n");
       usleep(100 * 1000);
       printf("Waiting for PHY_config_req\n");
     }
-    PHY_Config_t phycfg;
-    phycfg.Mod_id = Mod_idP;
-    phycfg.CC_id  = CC_idP;
-    phycfg.cfg    = &RC.mac[Mod_idP]->config[CC_idP];
-
-    if (RC.mac[Mod_idP]->if_inst->PHY_config_req) RC.mac[Mod_idP]->if_inst->PHY_config_req(&phycfg); 
   }
+
+  PHY_Config_t phycfg;
+  phycfg.Mod_id = Mod_idP;
+  phycfg.CC_id  = CC_idP;
+  phycfg.cfg    = &RC.mac[Mod_idP]->config[CC_idP];
+
+  LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
+  if (RC.mac[Mod_idP]->if_inst->PHY_config_req) RC.mac[Mod_idP]->if_inst->PHY_config_req(&phycfg); 
+  LOG_E(MAC, "%s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
+
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT);
 
   return(0);			   
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index 570e89494fb..efb3615a818 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -436,7 +436,7 @@ void clear_nfapi_information(eNB_MAC_INST *eNB,int CC_idP,frame_t frameP,sub_fra
 
     TX_req[CC_idP].tx_request_body.number_of_pdus                 = 0;
 
-    LOG_D(MAC,"%s() SFN_SF:%d%d ZERO PDUs of TX_req:(SFN_SF:%d):%d UL_req:(SFN_SF:%d):%d HI_DCI0_req:(SFN_SF:%d):dci:%d hi:%d DL:(SFN_SF:%d):dci:%d DL:pdu:%d\n", 
+    if (0) LOG_D(MAC,"%s() SFN_SF:%d%d ZERO PDUs of TX_req:(SFN_SF:%d):%d UL_req:(SFN_SF:%d):%d HI_DCI0_req:(SFN_SF:%d):dci:%d hi:%d DL:(SFN_SF:%d):dci:%d DL:pdu:%d\n", 
         __FUNCTION__,
         frameP, subframeP,
         NFAPI_SFNSF2DEC(TX_req[CC_idP].sfn_sf),
@@ -474,7 +474,7 @@ void copy_ulreq(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP)
 
     if (ul_req->ul_config_request_body.number_of_pdus>0)
     {
-      LOG_E(PHY, "%s() active NOW (frameP:%d subframeP:%d) pdus:%d\n", __FUNCTION__, frameP, subframeP, ul_req->ul_config_request_body.number_of_pdus);
+      LOG_D(PHY, "%s() active NOW (frameP:%d subframeP:%d) pdus:%d\n", __FUNCTION__, frameP, subframeP, ul_req->ul_config_request_body.number_of_pdus);
     }
 
     memcpy((void*)ul_req->ul_config_request_body.ul_config_pdu_list,
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c
index 182ca6443da..8b2b47c4507 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c
@@ -221,7 +221,7 @@ void add_msg3(module_id_t module_idP,int CC_id, RA_TEMPLATE *RA_template, frame_
 	// save UL scheduling information for preprocessor
 	for (j=0;j<RA_template->msg3_nb_rb;j++) cc->vrb_map_UL[RA_template->msg3_first_rb+j]=1;
 	
-	LOG_D(MAC,"[eNB %d][PUSCH-RA %x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) RA (mcs %d, first rb %d, nb_rb %d,round %d)\n",
+	LOG_I(MAC,"[eNB %d][PUSCH-RA %x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) RA (mcs %d, first rb %d, nb_rb %d,round %d)\n",
 	      module_idP,RA_template->rnti,CC_id,frameP,subframeP,10,
 	      1,1,
 	      RA_template->msg3_round-1);
@@ -283,12 +283,8 @@ void generate_Msg2(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t
     }
   }
 
-  LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, RA_template->rach_resource_type:%d frameP:%d/%d RA_template:Msg2:%d/%d\n",module_idP,frameP,subframeP,RA_template->rach_resource_type,
-  frameP,
-  subframeP,
-  RA_template->Msg2_frame, 
-  RA_template->Msg2_subframe
-  );
+  LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, RA_template[rach_resource_type:%d Msg2:%d/%d]\n",module_idP,frameP,subframeP,
+      RA_template->rach_resource_type,RA_template->Msg2_frame,RA_template->Msg2_subframe);
 
   if (RA_template->rach_resource_type > 0) {
     
@@ -467,6 +463,7 @@ void generate_Msg2(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t
   else
 #endif
     {
+      LOG_E(MAC,"%s() Compare SFN/SF:%04d%d Msg2:%04d%d\n", __FUNCTION__,frameP,subframeP,RA_template->Msg2_frame,RA_template->Msg2_subframe);
 
       if ((RA_template->Msg2_frame == frameP) && (RA_template->Msg2_subframe == subframeP)) {
   struct timespec t;
@@ -685,8 +682,8 @@ void generate_Msg4(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t
 	      "[MAC][eNB Scheduler] CCCH not allocated\n");
   
   
-  LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d MSG4:SFN/SF:%d%d UE_id %d, rrc_sdu_length %d\n",
-	module_idP, CC_idP, frameP, subframeP,RA_template->Msg4_frame,RA_template->Msg4_subframe,UE_id, rrc_sdu_length);
+  LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d MSG4:SFN/SF:%d%d UE_id %d, rrc_sdu_length %d harq_pid %d\n",
+	module_idP, CC_idP, frameP, subframeP,RA_template->Msg4_frame,RA_template->Msg4_subframe,UE_id, rrc_sdu_length, RA_template->harq_pid);
   
   
 #ifdef Rel14
@@ -1198,7 +1195,7 @@ void check_Msg4_retransmission(module_id_t module_idP,int CC_idP,frame_t frameP,
   dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; 
   N_RB_DL       = to_prb(cc[CC_idP].mib->message.dl_Bandwidth);
   
-  LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Checking if Msg4 for harq_pid %d was acknowledged (round %d) RA_template[Msg4:SFN/SF:%d/%d]\n",
+  LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Checking if Msg4 for harq_pid %d was acknowledged (round %d) RA_template[Msg4:SFN/SF:%d/%d]\n",
 	module_idP,CC_idP,frameP,subframeP,RA_template->harq_pid,round, RA_template->Msg4_frame, RA_template->Msg4_subframe);
 
   if (round!=8) {
@@ -1322,8 +1319,8 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP)
 
       if (RA_template->RA_active == TRUE) {
 
-        LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA %d is active (generate RAR %d, generate_Msg4 %d[SFN/SF:%d%d], wait_ack_Msg4 %d, rnti %x)\n",
-              module_idP,frameP,subframeP,CC_id,i,RA_template->generate_rar,RA_template->generate_Msg4,RA_template->Msg4_frame,RA_template->Msg4_subframe,RA_template->wait_ack_Msg4, RA_template->rnti);
+        LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA %d is active (generate RAR %d[SFN/SF:%d%d], generate_Msg4 %d[SFN/SF:%d%d], wait_ack_Msg4 %d, rnti %x)\n",
+              module_idP,frameP,subframeP,CC_id,i,RA_template->generate_rar,RA_template->Msg2_frame,RA_template->Msg2_subframe,RA_template->generate_Msg4,RA_template->Msg4_frame,RA_template->Msg4_subframe,RA_template->wait_ack_Msg4, RA_template->rnti);
 
         if      (RA_template->generate_rar == 1)  generate_Msg2(module_idP,CC_id,frameP,subframeP,RA_template);
 	else if (RA_template->generate_Msg4 == 1) generate_Msg4(module_idP,CC_id,frameP,subframeP,RA_template);
@@ -1365,7 +1362,7 @@ void initiate_ra_proc(module_id_t module_idP,
     ext4_prach=cc->radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310;
     prach_ParametersListCE_r13= &ext4_prach->prach_ParametersListCE_r13;
   }
-  LOG_E(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d  Initiating RA procedure for preamble index %d\n",module_idP,CC_id,frameP,subframeP,preamble_index);
+  LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d  Initiating RA procedure for preamble index %d\n",module_idP,CC_id,frameP,subframeP,preamble_index);
 #ifdef Rel14
   LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d  PRACH resource type %d\n",module_idP,CC_id,frameP,subframeP,rach_resource_type);
 #endif
@@ -1389,7 +1386,6 @@ void initiate_ra_proc(module_id_t module_idP,
       uint16_t msg2_frame = frameP;
       uint16_t msg2_subframe = subframeP;
       int offset;
-      LOG_D(MAC,"Frame %d, Subframe %d: Activating RA process %d\n",frameP,subframeP,i);
       RA_template[i].RA_active          = TRUE;
       RA_template[i].generate_rar       = 1;
       RA_template[i].generate_Msg4      = 0;
@@ -1406,13 +1402,15 @@ void initiate_ra_proc(module_id_t module_idP,
       if (nfapi_mode)
         offset = 7;
       else
-        offset = 4;
+        offset = 5;
 
       add_subframe(&msg2_frame, &msg2_subframe, offset);
 
       RA_template[i].Msg2_frame         = msg2_frame;
       RA_template[i].Msg2_subframe      = msg2_subframe;
 
+      LOG_E(MAC,"%s() Msg2[%04d%d] SFN/SF:%04d%d offset:%d\n", __FUNCTION__,RA_template[i].Msg2_frame,RA_template[i].Msg2_subframe,frameP,subframeP,offset);
+
       /* TODO: find better procedure to allocate RNTI */
       do {
         RA_template[i].rnti = taus();
@@ -1427,8 +1425,9 @@ void initiate_ra_proc(module_id_t module_idP,
       if (loop == 100) { printf("%s:%d:%s: FATAL ERROR! contact the authors\n", __FILE__, __LINE__, __FUNCTION__); abort(); }
       RA_template[i].RA_rnti        = ra_rnti;
       RA_template[i].preamble_index = preamble_index;
-      LOG_E(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Activating RAR generation in Frame %d, subframe %d for process %d, rnti %x, RA_active %d\n",
-            module_idP,CC_id,frameP,
+
+      LOG_E(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Subframe %d: Activating RAR generation (Msg2) in Frame %d, subframe %d for process %d, rnti %x, RA_active %d\n",
+            module_idP,CC_id,frameP,subframeP,
 	    RA_template[i].Msg2_frame,
 	    RA_template[i].Msg2_subframe,
 	    i,RA_template[i].rnti,
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
index 1768200318c..7ecb0778ef0 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
@@ -3132,7 +3132,7 @@ void extract_harq(module_id_t mod_idP,int CC_idP,int UE_id,frame_t frameP,sub_fr
         if (tmode[0]==1 || tmode[0]==2 || tmode[0]==5 || tmode[0]==6 || tmode[0]==7) { // NOTE: have to handle the case of TM9-10 with 1 antenna port
           // single ACK/NAK bit
           AssertFatal(num_ack_nak==1,"num_ack_nak %d > 1 for 1 CC and single-layer transmission\n",num_ack_nak);
-          AssertFatal(sched_ctl->round[CC_idP][harq_pid]<8,"Got ACK/NAK for inactive harq_pid %d for UE %d/%x\n",harq_pid,UE_id,rnti);
+          AssertFatal(sched_ctl->round[CC_idP][harq_pid]<8,"Got ACK/NAK for inactive harq_pid %d for UE %d/%x SFN/SF:%d%d\n",harq_pid,UE_id,rnti,frameP,subframeP);
           AssertFatal(pdu[0] == 1 || pdu[0] == 2 || pdu[0] == 4,
                       "Received ACK/NAK %d which is not 1 or 2 for harq_pid %d from UE %d/%x\n",pdu[0],harq_pid,UE_id,rnti);
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
index 937036d67e0..4afd40e27b1 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
@@ -892,7 +892,7 @@ void schedule_ulsch_rnti(module_id_t   module_idP,
   nfapi_ul_config_request_t *ul_req_tmp            = &eNB->UL_req_tmp[CC_id][sched_subframeP];
   nfapi_ul_config_request_body_t *ul_req_tmp_body  = &ul_req_tmp->ul_config_request_body;
 
-  LOG_D(MAC,"entering ulsch preprocesor\n");
+  //LOG_D(MAC,"entering ulsch preprocesor\n");
   ulsch_scheduler_pre_processor(module_idP,
                                 frameP,
                                 subframeP,
diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c
index e894aa06c71..8f4720024b5 100644
--- a/openair2/PHY_INTERFACE/IF_Module.c
+++ b/openair2/PHY_INTERFACE/IF_Module.c
@@ -214,7 +214,7 @@ void handle_ulsch(UL_IND_t *UL_info) {
         } //if (UL_info->crc_ind.crc_pdu_list[j].rx_ue_information.rnti ==
         //    UL_info->rx_ind.rx_pdu_list[i].rx_ue_information.rnti)
       } //    for (j=0;j<UL_info->crc_ind.crc_indication_body.number_of_crcs;j++)
-      AssertFatal(j<UL_info->crc_ind.crc_indication_body.number_of_crcs,"Couldn't find matchin CRC indication\n");
+      AssertFatal(j<UL_info->crc_ind.crc_indication_body.number_of_crcs,"SFN/SF:%d Couldn't find matchin CRC indication RX_IND:PDUs:%d CRCs:%d\n", NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf),UL_info->rx_ind.rx_indication_body.number_of_pdus, UL_info->crc_ind.crc_indication_body.number_of_crcs);
     } //   for (i=0;i<UL_info->rx_ind.number_of_pdus;i++)
   }
 
diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c
index 773f6c85796..3b83d82a719 100644
--- a/openair2/RRC/LITE/rrc_eNB.c
+++ b/openair2/RRC/LITE/rrc_eNB.c
@@ -135,6 +135,8 @@ init_SI(
   SystemInformationBlockType1_v1310_IEs_t *sib1_v13ext=(SystemInformationBlockType1_v1310_IEs_t *)NULL;
 #endif
 
+  LOG_E(RRC,"%s()\n\n\n\n",__FUNCTION__);
+
   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MIB = (uint8_t*) malloc16(4);
   // copy basic parameters
   RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId      = configuration->Nid_cell[CC_id];
@@ -282,7 +284,7 @@ init_SI(
   }
 #endif
 
-  LOG_I(RRC, "About to call rrc_mac_config_req_eNB\n");
+  LOG_E(RRC, "About to call rrc_mac_config_req_eNB\n");
 
   rrc_mac_config_req_eNB(ctxt_pP->module_id, CC_id,
 			 RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId,
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
index da94ad09c52..9218cf876f4 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
@@ -37,14 +37,14 @@ eNBs =
       downlink_frequency      			      = 2685000000L;
       uplink_frequency_offset 			      = -120000000;
       Nid_cell					      = 0;
-      // N_RB_DL                 			      = 50;
+# N_RB_DL                 			      = 50;
       N_RB_DL                 			      = 25;
       Nid_cell_mbsfn          			      = 0;
       nb_antenna_ports                                = 1;
       nb_antennas_tx          			      = 1;
       nb_antennas_rx          			      = 1;
       tx_gain                                            = 90;
-      rx_gain                                            = 125;
+      rx_gain                                            = 115;
       pbch_repetition                                 = "FALSE";
       prach_root              			      = 0;
       prach_config_index      			      = 0;
@@ -190,19 +190,21 @@ RUs = (
     }
 );  
 
-log_config = {
-  global_log_level                      ="debug";
-  global_log_verbosity                  ="medium";
-  hw_log_level                          ="info";
-  hw_log_verbosity                      ="medium";
-  phy_log_level                         ="debug";
-  phy_log_verbosity                     ="medium";
-  mac_log_level                         ="info";
-  mac_log_verbosity                     ="high";
-  rlc_log_level                         ="info";
-  rlc_log_verbosity                     ="medium";
-  pdcp_log_level                        ="info";
-  pdcp_log_verbosity                    ="medium";
-  rrc_log_level                         ="info";
-  rrc_log_verbosity                     ="medium";
-};
+     log_config :
+     {
+       global_log_level                      ="debug";
+       global_log_verbosity                  ="medium";
+       hw_log_level                          ="info";
+       hw_log_verbosity                      ="medium";
+       phy_log_level                         ="info";
+       phy_log_verbosity                     ="low";
+       mac_log_level                         ="info";
+       mac_log_verbosity                     ="medium";
+       rlc_log_level                         ="info";
+       rlc_log_verbosity                     ="high";
+       pdcp_log_level                        ="info";
+       pdcp_log_verbosity                    ="medium";
+       rrc_log_level                         ="debug";
+       rrc_log_verbosity                     ="high";
+    };
+
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/oaiL1.nfapi.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/oaiL1.nfapi.usrpb210.conf
index 888da118714..88d653b7b2e 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/oaiL1.nfapi.usrpb210.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/oaiL1.nfapi.usrpb210.conf
@@ -1,9 +1,9 @@
 log_config = {
-  global_log_level                      ="info";
+  global_log_level                      ="debug";
   global_log_verbosity                  ="medium";
   hw_log_level                          ="info";
   hw_log_verbosity                      ="medium";
-  phy_log_level                         ="debug";
+  phy_log_level                         ="info";
   phy_log_verbosity                     ="medium";
   mac_log_level                         ="info";
   mac_log_verbosity                     ="medium";
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf
index 2c155a76f67..5818933c48f 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf
@@ -164,23 +164,6 @@ eNBs =
   }
 );
 
-log_config = {
-  global_log_level                      ="crit";
-  global_log_verbosity                  ="medium";
-  hw_log_level                          ="info";
-  hw_log_verbosity                      ="medium";
-  phy_log_level                         ="debug";
-  phy_log_verbosity                     ="medium";
-  mac_log_level                         ="info";
-  mac_log_verbosity                     ="medium";
-  rlc_log_level                         ="info";
-  rlc_log_verbosity                     ="medium";
-  pdcp_log_level                        ="info";
-  pdcp_log_verbosity                    ="medium";
-  rrc_log_level                         ="info";
-  rrc_log_verbosity                     ="medium";
-};
-
 MACRLCs = (
 	{
 	num_cc = 1;
@@ -196,3 +179,22 @@ MACRLCs = (
 	tr_n_preference = "local_RRC";
         }  
 );
+
+     log_config :
+     {
+       global_log_level                      ="debug";
+       global_log_verbosity                  ="medium";
+       hw_log_level                          ="info";
+       hw_log_verbosity                      ="medium";
+       phy_log_level                         ="info";
+       phy_log_verbosity                     ="medium";
+       mac_log_level                         ="debug";
+       mac_log_verbosity                     ="high";
+       rlc_log_level                         ="debug";
+       rlc_log_verbosity                     ="high";
+       pdcp_log_level                        ="info";
+       pdcp_log_verbosity                    ="medium";
+       rrc_log_level                         ="info";
+       rrc_log_verbosity                     ="high";
+    };
+
diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c
index f668191aa1a..c3972ba2180 100644
--- a/targets/RT/USER/lte-enb.c
+++ b/targets/RT/USER/lte-enb.c
@@ -121,7 +121,7 @@ extern int transmission_mode;
 
 extern int oaisim_flag;
 
-uint16_t sf_ahead=2;
+uint16_t sf_ahead=4;
 
 //pthread_t                       main_eNB_thread;
 
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index c58591c7b1b..0dec98e137a 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -1275,6 +1275,7 @@ int main( int argc, char **argv )
   {
     case 0:
       nfapi_mode_str = "MONOLITHIC";
+      break;
     case 1:
       nfapi_mode_str = "PNF";
       break;
@@ -1394,7 +1395,9 @@ int main( int argc, char **argv )
   sync_var=0;
   pthread_cond_broadcast(&sync_cond);
   pthread_mutex_unlock(&sync_mutex);
+  printf("About to call end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
   end_configmodule();
+  printf("Called end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
 
   // wait for end of program
   printf("TYPE <CTRL-C> TO TERMINATE\n");
@@ -1403,11 +1406,14 @@ int main( int argc, char **argv )
 #if defined(ENABLE_ITTI)
   printf("Entering ITTI signals handler\n");
   itti_wait_tasks_end();
+  printf("Returned from ITTI signal handler\n");
   oai_exit=1;
+  printf("oai_exit=%d\n",oai_exit);
 #else
 
   while (oai_exit==0)
     rt_sleep_ns(100000000ULL);
+  printf("Terminating application - oai_exit=%d\n",oai_exit);
 
 #endif
 
-- 
GitLab