From 43def3d76cf64b3ed3ac670b8f86b76c52bdbef6 Mon Sep 17 00:00:00 2001
From: Raymond Knopp <raymond.knopp@eurecom.fr>
Date: Thu, 20 Sep 2018 01:38:57 +0200
Subject: [PATCH] crashes inside DU_send_UL_RRC_MESSAGE_TRANSFER

---
 openair2/F1AP/f1ap_du_rrc_message_transfer.c | 18 ++++++++++++++++--
 openair2/LAYER2/MAC/eNB_scheduler_ulsch.c    |  2 +-
 openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c       |  3 ++-
 openair2/LAYER2/RLC/rlc.c                    |  8 ++++----
 openair2/LAYER2/RLC/rlc_mac.c                |  6 +++---
 5 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.c b/openair2/F1AP/f1ap_du_rrc_message_transfer.c
index b848f57659..651491aba7 100644
--- a/openair2/F1AP/f1ap_du_rrc_message_transfer.c
+++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.c
@@ -209,7 +209,7 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t       instance,
 	LOG_I(RRC,
 	      "Logical Channel DL-CCCH (SRB0), Received RRCConnectionSetup DU_ID %x/RNTI %x\n",  
 	      du_ue_f1ap_id,
-	      f1ap_get_rnti_by_du_id(&f1ap_du_ue[0],du_ue_f1ap_id));
+	      f1ap_get_rnti_by_du_id(&f1ap_du_ue[instance],du_ue_f1ap_id));
 	// Get configuration
 
 	RRCConnectionSetup_t* rrcConnectionSetup = &dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup;
@@ -243,6 +243,20 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t       instance,
 	  }
 	}
 
+	protocol_ctxt_t ctxt;
+	ctxt.rnti      = f1ap_get_rnti_by_du_id(&f1ap_du_ue[instance],du_ue_f1ap_id);
+        ctxt.module_id = instance;
+	ctxt.enb_flag  = 1;
+	rrc_rlc_config_asn1_req(&ctxt,
+				SRB_configList,
+				(DRB_ToAddModList_t*) NULL,
+				(DRB_ToReleaseList_t*) NULL
+#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0))
+				, (PMCH_InfoList_r9_t *) NULL,
+				0,0
+#   endif
+				);
+	
 	// This should be somewhere in the f1ap_cudu_ue_inst_t
 	int macrlc_instance = 0; 
 
@@ -318,7 +332,7 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t       instance,
 int DU_send_UL_RRC_MESSAGE_TRANSFER(instance_t                instance,
                                     f1ap_ul_rrc_message_t    *f1ap_ul_rrc) {
 
-  LOG_D(DU_F1AP, "DU_send_UL_RRC_MESSAGE_TRANSFER \n");
+  LOG_I(DU_F1AP, "DU_send_UL_RRC_MESSAGE_TRANSFER \n");
 
   F1AP_F1AP_PDU_t                pdu;
   F1AP_ULRRCMessageTransfer_t    *out;
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
index e1fce9c5f2..69a6ff4612 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
@@ -686,7 +686,7 @@ rx_sdu(const module_id_t enb_mod_idP,
           //UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer += UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer / 4;
         }
 
-	LOG_D(MAC,
+	LOG_I(MAC,
 	      "[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DCCH, received %d bytes form UE %d on LCID %d \n",
 	      enb_mod_idP, CC_idP, frameP, rx_lengths[i], UE_id,
 	      rx_lcids[i]);
diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c
index d4e43fda47..e3f2e22f8e 100644
--- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c
+++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c
@@ -42,7 +42,7 @@
 #include "UL-AM-RLC.h"
 #include "DL-AM-RLC.h"
 
-
+#define TRACE_RLC_AM_PDU 1
 //-----------------------------------------------------------------------------
 uint32_t
 rlc_am_get_status_pdu_buffer_occupancy(
@@ -936,6 +936,7 @@ rlc_am_mac_data_indication (
 
   (void)l_rlc_p; /* avoid gcc warning "unused variable" */
 
+  LOG_I(RLC, "In rlc_am_mac_indication: size %d\n",tb_size_in_bytes);
 #if TRACE_RLC_AM_PDU || MESSAGE_CHART_GENERATOR
 
   if (data_indP.data.nb_elements > 0) {
diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c
index da568c86f8..3ecd794a06 100644
--- a/openair2/LAYER2/RLC/rlc.c
+++ b/openair2/LAYER2/RLC/rlc.c
@@ -665,15 +665,15 @@ void rlc_data_ind     (
   //-----------------------------------------------------------------------------
 
 
-#if defined(TRACE_RLC_PAYLOAD)
-  LOG_D(RLC, PROTOCOL_CTXT_FMT"[%s %u] Display of rlc_data_ind: size %u\n",
+  //#if defined(TRACE_RLC_PAYLOAD)
+  LOG_I(RLC, PROTOCOL_CTXT_FMT"[%s %u] Display of rlc_data_ind: size %u\n",
         PROTOCOL_CTXT_ARGS(ctxt_pP),
         (srb_flagP) ? "SRB" : "DRB",
         rb_idP,
         sdu_sizeP);
 
-  rlc_util_print_hex_octets(RLC, (unsigned char*)sdu_pP->data, sdu_sizeP);
-#endif
+  //  rlc_util_print_hex_octets(RLC, (unsigned char*)sdu_pP->data, sdu_sizeP);
+  //#endif
 
 #if T_TRACER
   if (ctxt_pP->enb_flag)
diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c
index dbc2d1d342..b3d8d36dc5 100644
--- a/openair2/LAYER2/RLC/rlc_mac.c
+++ b/openair2/LAYER2/RLC/rlc_mac.c
@@ -38,7 +38,7 @@
 #include "assertions.h"
 #include "common/utils/LOG/vcd_signal_dumper.h"
 
-//#define DEBUG_MAC_INTERFACE 1
+#define DEBUG_MAC_INTERFACE 1
 
 //-----------------------------------------------------------------------------
 struct mac_data_ind mac_rlc_deserialize_tb (
@@ -260,7 +260,7 @@ void mac_rlc_data_ind     (
 #ifdef DEBUG_MAC_INTERFACE
 
   if (num_tbP) {
-    LOG_D(RLC, PROTOCOL_CTXT_FMT" MAC_RLC_DATA_IND on channel %d (%d), rb max %d, Num_tb %d\n",
+    LOG_I(RLC, PROTOCOL_CTXT_FMT" MAC_RLC_DATA_IND on channel %d (%d), rb max %d, Num_tb %d\n",
           PROTOCOL_CTXT_ARGS(&ctxt),
           channel_idP,
           RLC_MAX_LC,
@@ -292,7 +292,7 @@ void mac_rlc_data_ind     (
     rlc_mode = rlc_union_p->mode;
   } else {
     rlc_mode = RLC_MODE_NONE;
-    //AssertFatal (0 , "%s RLC not configured rb id %u lcid %u module %u!\n", __FUNCTION__, rb_id, channel_idP, ue_module_idP);
+    AssertFatal (0 , "%s RLC not configured lcid %u ! (h_rc %d)\n", __FUNCTION__,channel_idP,h_rc);
   }
 
   struct mac_data_ind data_ind = mac_rlc_deserialize_tb(buffer_pP, tb_sizeP, num_tbP, crcs_pP);
-- 
GitLab