From 4f93ef56d52ca6e78d5a09dd0422e282dcb71310 Mon Sep 17 00:00:00 2001
From: matzakos <panagiotis.matzakos@eurecom.fr>
Date: Tue, 20 Mar 2018 18:14:49 +0100
Subject: [PATCH] Fixed a bug. Now both UEs reaching RRC Connection
 Reconfiguration state about 90% of the executions. Less frequently appearing
 issues remain to be fixed.

---
 openair2/LAYER2/MAC/main_ue.c        |  4 +-
 openair2/PHY_INTERFACE/phy_stub_UE.c | 52 +++++++++-------
 openair2/RRC/LITE/rrc_UE.c           | 12 ++--
 targets/RT/USER/lte-ue.c             | 89 +++++++++++++++++++++++++++-
 4 files changed, 126 insertions(+), 31 deletions(-)

diff --git a/openair2/LAYER2/MAC/main_ue.c b/openair2/LAYER2/MAC/main_ue.c
index e9992dd665a..5c849d2bb0a 100644
--- a/openair2/LAYER2/MAC/main_ue.c
+++ b/openair2/LAYER2/MAC/main_ue.c
@@ -60,10 +60,10 @@ void dl_phy_sync_success(module_id_t module_idP, frame_t frameP, unsigned char e
 
     if (first_sync == 1 && !(mme_enabled == 1)) {
 	//layer2_init_UE(module_idP);
-    	LOG_I(MAC, "Panos-D: dl_phy_sync_success 1 \n");
+    	LOG_D(MAC, "Panos-D: dl_phy_sync_success 1 \n");
 	openair_rrc_ue_init(module_idP, eNB_index);
     } else {
-    	LOG_I(MAC, "Panos-D: dl_phy_sync_success 2 \n");
+    	LOG_D(MAC, "Panos-D: dl_phy_sync_success 2 \n");
 	rrc_in_sync_ind(module_idP, frameP, eNB_index);
     }
 }
diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c
index 9c819e56cc3..d5f0774b361 100644
--- a/openair2/PHY_INTERFACE/phy_stub_UE.c
+++ b/openair2/PHY_INTERFACE/phy_stub_UE.c
@@ -559,7 +559,7 @@ void fill_uci_harq_indication_UE_MAC(int Mod_id,
     //LOG_I(MAC, "Panos-D: fill_uci_harq_indication_UE_MAC 7 \n");
   UL_INFO->harq_ind.harq_indication_body.number_of_harqs++;
   //LOG_I(MAC, "Panos-D: fill_uci_harq_indication_UE_MAC 8 \n");
-  LOG_E(PHY,"Incremented eNB->UL_INFO.harq_ind.number_of_harqs:%d\n", UL_INFO->harq_ind.harq_indication_body.number_of_harqs);
+  LOG_D(PHY,"Incremented eNB->UL_INFO.harq_ind.number_of_harqs:%d\n", UL_INFO->harq_ind.harq_indication_body.number_of_harqs);
   pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
 
 }
@@ -577,7 +577,7 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
   // check if we have received a dci for this ue and ulsch descriptor is configured
 
   if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) {
-	  LOG_I(MAC, "Panos-D: handle_nfapi_ul_pdu_UE_MAC 2 \n");
+	  LOG_D(MAC, "Panos-D: handle_nfapi_ul_pdu_UE_MAC 2 \n");
     //AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0,
     //            "No existing UE ULSCH for rnti %x\n",rel8->rnti);
     LOG_D(PHY,"Applying UL config for UE, rnti %x for frame %d, subframe %d\n",
@@ -809,9 +809,7 @@ int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int timer_frame, int ti
   nfapi_ul_config_request_pdu_t* ul_config_pdu_list = req->ul_config_request_body.ul_config_pdu_list;
   //LOG_D(MAC, "Panos-D: ul_config_req_UE_MAC 1 \n");
 
-  //Panos: Not sure whether we should put the memory allocation here.
-  //*** Note we should find the right place to call free(UL_INFO).
-  UL_INFO = (UL_IND_t*)malloc(sizeof(UL_IND_t));
+
   //UL_INFO->rach_ind.rach_indication_body.preamble_list = (nfapi_preamble_pdu_t*)malloc(UL_INFO->rach_ind.rach_indication_body.number_of_preambles*sizeof(nfapi_preamble_pdu_t));
 
   /*UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = (nfapi_rx_indication_pdu_t*)malloc(sizeof(nfapi_rx_indication_pdu_t));
@@ -827,6 +825,13 @@ int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int timer_frame, int ti
   UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0;*/
 
 
+  /*
+
+
+  //Panos: Not sure whether we should put the memory allocation here.
+   //*** Note we should find the right place to call free(UL_INFO).
+   UL_INFO = (UL_IND_t*)malloc(sizeof(UL_IND_t));
+
   	UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = (nfapi_rx_indication_pdu_t*)malloc(req->ul_config_request_body.number_of_pdus*sizeof(nfapi_rx_indication_pdu_t));
   	UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
   	UL_INFO->rx_ind.header.message_id = 3225;
@@ -844,6 +849,9 @@ int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int timer_frame, int ti
   	UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0;
   	UL_INFO->sr_ind.header.message_id = 3225;
 
+  	*/
+
+
   //LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC total number of pdus: %d \n", req->ul_config_request_body.number_of_pdus);
   //Panos: Additional checks needed here to check if the UE is in PRACH mode.
 
@@ -863,7 +871,7 @@ int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int timer_frame, int ti
   //subtract_subframe(&sfn, &sf, 4);
 
 
-  LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC() TOTAL NUMBER OF UL_CONFIG PDUs: %d, SFN/SF: %d/%d \n", req->ul_config_request_body.number_of_pdus, timer_frame, timer_subframe);
+  LOG_D(MAC, "Panos-D: ul_config_req_UE_MAC() TOTAL NUMBER OF UL_CONFIG PDUs: %d, SFN/SF: %d/%d \n", req->ul_config_request_body.number_of_pdus, timer_frame, timer_subframe);
 
 
 
@@ -960,6 +968,10 @@ int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int timer_frame, int ti
     }
   }
 
+
+
+  /****
+
   if (UL_INFO->crc_ind.crc_indication_body.number_of_crcs>0)
   {
 	  //LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.number_of_crcs:%d CRC_IND:SFN/SF:%d\n", UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf));
@@ -979,7 +991,7 @@ int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int timer_frame, int ti
   }
   if(UL_INFO->harq_ind.harq_indication_body.number_of_harqs>0)
   {
-	  LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC 2.4, SFN/SF in REQ:%d.%d, SFN/SF of PNF counter:%d.%d, number_of_harqs: %d \n", sfn, sf, timer_frame, timer_subframe, UL_INFO->harq_ind.harq_indication_body.number_of_harqs);
+	  LOG_D(MAC, "Panos-D: ul_config_req_UE_MAC 2.4, SFN/SF in REQ:%d.%d, SFN/SF of PNF counter:%d.%d, number_of_harqs: %d \n", sfn, sf, timer_frame, timer_subframe, UL_INFO->harq_ind.harq_indication_body.number_of_harqs);
 	  oai_nfapi_harq_indication(&UL_INFO->harq_ind);
 	  //LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC 2.41 \n");
 	  UL_INFO->harq_ind.harq_indication_body.number_of_harqs =0;
@@ -993,15 +1005,6 @@ int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int timer_frame, int ti
 	  UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0;
   }
 
-  // Free ul_config_request
-  /*if(req->ul_config_request_body.ul_config_pdu_list != NULL){
-	  free(req->ul_config_request_body.ul_config_pdu_list);
-	  req->ul_config_request_body.ul_config_pdu_list = NULL;
-  }
-  free(req);
-  req = NULL;*/
-
-
   // Free UL_INFO messages
   //if(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list != NULL){
 	  free(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list);
@@ -1019,8 +1022,9 @@ int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int timer_frame, int ti
 	  free(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list);
 	  UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = NULL;
   //}
+
   free(UL_INFO);
-  UL_INFO = NULL;
+  UL_INFO = NULL;****/
 	}
 
   return 0;
@@ -1092,7 +1096,7 @@ int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req, module_id_t Mod_id) //,
   for (int i=0;i<req->dl_config_request_body.number_pdu;i++)
   {
     //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sfn/sf:%d PDU[%d] size:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size);
-	  LOG_E(MAC, "dl_config_req_UE_MAC 2 Received real ones: sfn/sf:%d.%d PDU[%d] size:%d\n", sfn, sf, i, dl_config_pdu_list[i].pdu_size);
+	  //LOG_E(MAC, "dl_config_req_UE_MAC 2 Received real ones: sfn/sf:%d.%d PDU[%d] size:%d\n", sfn, sf, i, dl_config_pdu_list[i].pdu_size);
 
     if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)
     {
@@ -1112,7 +1116,9 @@ int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req, module_id_t Mod_id) //,
 
 				if(dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index <= tx_req_num_elems -1){
 				//if(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL){
-					LOG_E(MAC, "dl_config_req_UE_MAC 2 Received data: sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d, tx_req_num_elems: %d \n", NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index, tx_req_num_elems);
+
+					//LOG_E(MAC, "dl_config_req_UE_MAC 2 Received data: sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d, tx_req_num_elems: %d \n", NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index, tx_req_num_elems);
+
 					ue_send_sdu(Mod_id, 0, sfn, sf,
 							tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data,
 							tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length,
@@ -1131,8 +1137,10 @@ int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req, module_id_t Mod_id) //,
 			dl_config_pdu_tmp = &dl_config_pdu_list[i+1];
 			if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti == 0xFFFF){
 				//pdu = Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data;
-				LOG_E(MAC,"dl_config_req_UE_MAC 3 Received SI: [PDU:%d] NFAPI_DL_CONFIG_DLSCH_PDU_TYPE TX:%d/%d RX:%d/%d transport_blocks:%d pdu_index:%d sdu:%p\n",
-				            i, sfn, sf, sfn, sf, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.transport_blocks, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index, tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data);
+
+				/*LOG_E(MAC,"dl_config_req_UE_MAC 3 Received SI: [PDU:%d] NFAPI_DL_CONFIG_DLSCH_PDU_TYPE TX:%d/%d RX:%d/%d transport_blocks:%d pdu_index:%d sdu:%p\n",
+				            i, sfn, sf, sfn, sf, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.transport_blocks, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index, tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data);*/
+
 				if(dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index <= tx_req_num_elems -1){
 				//if(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL){
 					ue_decode_si(Mod_id, 0, sfn, 0,
@@ -1192,7 +1200,7 @@ int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req, module_id_t Mod_id) //,
     	// BCH case
     	// Last parameter is 1 if first time synchronization and zero otherwise. Not sure which value to put
     	// for our case.
-    	LOG_E(MAC,"dl_config_req_UE_MAC 4 Received MIB: sfn/sf: %d.%d \n", sfn, sf);
+    	//LOG_E(MAC,"dl_config_req_UE_MAC 4 Received MIB: sfn/sf: %d.%d \n", sfn, sf);
     	if(UE_mac_inst[Mod_id].UE_mode[0] == NOT_SYNCHED){
     		dl_phy_sync_success(Mod_id,sfn,0, 1);
     		LOG_E(MAC,"dl_config_req_UE_MAC 5 Received MIB: UE_mode: %d\n", UE_mac_inst[Mod_id].UE_mode[0]);
diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c
index 92579b7d8e2..f34cac6bd11 100644
--- a/openair2/RRC/LITE/rrc_UE.c
+++ b/openair2/RRC/LITE/rrc_UE.c
@@ -3908,12 +3908,12 @@ uint64_t arfcn_to_freq(long arfcn) {
 //-----------------------------------------------------------------------------
  int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index )
 {
-	LOG_I( RRC, "Panos-D: decode_SI 1 \n");
+  //LOG_D( RRC, "Panos-D: decode_SI 1 \n");
   SystemInformation_t** si = &UE_rrc_inst[ctxt_pP->module_id].si[eNB_index];
   int new_sib = 0;
   SystemInformationBlockType1_t* sib1 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index];
 
-  LOG_I( RRC, "Panos-D: decode_SI 2 \n");
+  //LOG_D( RRC, "Panos-D: decode_SI 2 \n");
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SI, VCD_FUNCTION_IN );
 
   // Dump contents
@@ -3922,12 +3922,12 @@ uint64_t arfcn_to_freq(long arfcn) {
     LOG_I( RRC, "[UE] (*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count %d\n",
            (*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count );
   } else {
-	  LOG_I( RRC, "Panos-D: decode_SI 2.3 \n");
+	  //LOG_D( RRC, "Panos-D: decode_SI 2.3 \n");
     LOG_D( RRC, "[UE] Unknown criticalExtension version (not Rel8)\n" );
     return -1;
   }
 
-  LOG_I( RRC, "Panos-D: decode_SI 3 \n");
+  LOG_D( RRC, "Panos-D: decode_SI 3 \n");
   for (int i=0; i<(*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count; i++) {
     LOG_I( RRC, "SI count %d\n", i );
     struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member *typeandinfo;
@@ -3935,7 +3935,7 @@ uint64_t arfcn_to_freq(long arfcn) {
 
     switch(typeandinfo->present) {
     case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2:
-    	LOG_I( RRC, "Panos-D: decode_SI 4 \n");
+    	//LOG_D( RRC, "Panos-D: decode_SI 4 \n");
       if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&2) == 0) {
 	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=2;
 	new_sib=1;
@@ -4025,7 +4025,7 @@ uint64_t arfcn_to_freq(long arfcn) {
       break; // case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2
 
     case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3:
-    	LOG_I( RRC, "Panos-D: decode_SI 5 \n");
+    	//LOG_D( RRC, "Panos-D: decode_SI 5 \n");
       if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&4) == 0) {
 	UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=4;
 	new_sib=1;
diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c
index 82cb720fbb8..6ed3d2d66ec 100644
--- a/targets/RT/USER/lte-ue.c
+++ b/targets/RT/USER/lte-ue.c
@@ -968,6 +968,31 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) {
 
     //if(timer_frame%5 == 0 && timer_subframe%10 == 0)
     	init_ra_UE++;
+
+    	//Panos: Not sure whether we should put the memory allocation here.
+    	//*** Note we should find the right place to call free(UL_INFO).
+    	UL_INFO = (UL_IND_t*)malloc(sizeof(UL_IND_t));
+
+    	UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = (nfapi_rx_indication_pdu_t*)malloc(10*sizeof(nfapi_rx_indication_pdu_t));
+    	UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
+    	UL_INFO->rx_ind.header.message_id = 3225;
+
+
+    	UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = (nfapi_crc_indication_pdu_t*)malloc(10*sizeof(nfapi_crc_indication_pdu_t));
+    	UL_INFO->crc_ind.crc_indication_body.number_of_crcs = 0;
+    	UL_INFO->crc_ind.header.message_id = 3225;
+
+    	UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = (nfapi_harq_indication_pdu_t*)malloc(10*sizeof(nfapi_harq_indication_pdu_t));
+    	UL_INFO->harq_ind.harq_indication_body.number_of_harqs = 0;
+    	UL_INFO->harq_ind.header.message_id = 3225;
+
+    	UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = (nfapi_sr_indication_pdu_t*)malloc(10*sizeof(nfapi_sr_indication_pdu_t));
+    	UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0;
+    	UL_INFO->sr_ind.header.message_id = 3225;
+
+
+
+
     for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++) {
     	//LOG_I(MAC, "Panos-D: UE_phy_stub_single_thread_rxn_txnp4, NB_UE_INST:%d, Mod_id:%d \n", NB_UE_INST, Mod_id);
     	UE = PHY_vars_UE_g[Mod_id][0];
@@ -1034,7 +1059,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) {
       }
       //if(UE_mac_inst[Mod_id].hi_dci0_req!= NULL){
       if (UE_mac_inst[Mod_id].hi_dci0_req!=NULL && UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list!=NULL){
-    	  LOG_I( MAC, "Panos-D: UE_phy_stub_thread_rxn_txnp4 after oai_subframe_ind 4 \n");
+    	  //LOG_I( MAC, "Panos-D: UE_phy_stub_thread_rxn_txnp4 after oai_subframe_ind 4 \n");
     	  hi_dci0_req_UE_MAC(UE_mac_inst[Mod_id].hi_dci0_req, Mod_id);
     	  //if(UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list!=NULL){
     		  free(UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list);
@@ -1172,6 +1197,68 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) {
     	  free(tx_request_pdu_list);
       	  tx_request_pdu_list = NULL;
       }
+
+
+    if (UL_INFO->crc_ind.crc_indication_body.number_of_crcs>0)
+      {
+    	  //LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.number_of_crcs:%d CRC_IND:SFN/SF:%d\n", UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf));
+    	  LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC 2.2, SFN/SF of PNF counter:%d.%d, number_of_crcs: %d \n", timer_frame, timer_subframe, UL_INFO->crc_ind.crc_indication_body.number_of_crcs);
+    	  oai_nfapi_crc_indication(&UL_INFO->crc_ind);
+    	  //LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC 2.21 \n");
+    	  UL_INFO->crc_ind.crc_indication_body.number_of_crcs = 0;
+      }
+      if (UL_INFO->rx_ind.rx_indication_body.number_of_pdus>0)
+      {
+    	  //LOG_D(PHY,"UL_info->rx_ind.number_of_pdus:%d RX_IND:SFN/SF:%d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf));
+    	  LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC 2.3, SFN/SF of PNF counter:%d.%d, number_of_pdus: %d \n", timer_frame, timer_subframe, UL_INFO->rx_ind.rx_indication_body.number_of_pdus);
+    	  //LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC 2.3 \n");
+    	  oai_nfapi_rx_ind(&UL_INFO->rx_ind);
+    	  //LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC 2.31 \n");
+    	  UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
+      }
+      if(UL_INFO->harq_ind.harq_indication_body.number_of_harqs>0)
+      {
+    	  LOG_D(MAC, "Panos-D: ul_config_req_UE_MAC 2.4, SFN/SF of PNF counter:%d.%d, number_of_harqs: %d \n", timer_frame, timer_subframe, UL_INFO->harq_ind.harq_indication_body.number_of_harqs);
+    	  oai_nfapi_harq_indication(&UL_INFO->harq_ind);
+    	  //LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC 2.41 \n");
+    	  UL_INFO->harq_ind.harq_indication_body.number_of_harqs =0;
+
+      }
+      if(UL_INFO->sr_ind.sr_indication_body.number_of_srs>0)
+      {
+    	  LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC 2.5, SFN/SF of PNF counter:%d.%d, number_of_srs: %d \n", timer_frame, timer_subframe, UL_INFO->sr_ind.sr_indication_body.number_of_srs);
+    	  oai_nfapi_sr_indication(&UL_INFO->sr_ind);
+    	  //LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC 2.51 \n");
+    	  UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0;
+      }
+
+      // Free UL_INFO messages
+      //if(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list != NULL){
+    	  free(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list);
+    	  UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = NULL;
+      //}
+      //if(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list != NULL){
+    	  free(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list);
+    	  UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL;
+      //}
+      //if(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list !=NULL){
+    	  free(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list);
+    	  UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = NULL;
+      //}
+      //if(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list!=NULL){
+    	  free(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list);
+    	  UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = NULL;
+      //}
+
+      free(UL_INFO);
+      UL_INFO = NULL;
+
+
+
+
+
+
+
   }
   // thread finished
   free(arg);
-- 
GitLab