diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c
index 4869feaa6559a1cacd973b972edaeae6566709bb..7236d65300e02be9aedd4bfb43f01b5af71ada89 100644
--- a/targets/SIMU/USER/oaisim.c
+++ b/targets/SIMU/USER/oaisim.c
@@ -375,38 +375,7 @@ static s32 UE_id = 0, eNB_id = 0;
static s32 RN_id=0;
#endif
-#if defined(ENABLE_ITTI)
-int itti_create_task_successful(void){
-# if defined(ENABLE_USE_MME)
- if (itti_create_task(TASK_SCTP, sctp_eNB_task, NULL) < 0) {
- LOG_E(EMU, "Create task failed");
- LOG_D(EMU, "Initializing SCTP task interface: FAILED\n");
- return -1;
- }
- if (itti_create_task(TASK_S1AP, s1ap_eNB_task, NULL) < 0) {
- LOG_E(EMU, "Create task failed");
- LOG_D(EMU, "Initializing S1AP task interface: FAILED\n");
- return -1;
- }
-# endif
-
- if (itti_create_task(TASK_L2L1, l2l1_task, NULL) < 0) {
- LOG_E(EMU, "Create task failed");
- LOG_D(EMU, "Initializing L2L1 task interface: FAILED\n");
- return -1;
- }
-
- /* Last task to create, others task must be ready before its start */
- if (itti_create_task(TASK_ENB_APP, eNB_app_task, NULL) < 0) {
- LOG_E(EMU, "Create task failed");
- LOG_D(EMU, "Initializing eNB APP task interface: FAILED\n");
- return -1;
- }
- return 1;
-}
-#endif
-
-void *l2l1_task(void *args_p) {
+static void *l2l1_task(void *args_p) {
// Framing variables
s32 slot, last_slot, next_slot;
@@ -423,14 +392,16 @@ void *l2l1_task(void *args_p) {
itti_mark_task_ready (TASK_L2L1);
- /* Wait for the initialize message */
- do {
- if (message_p != NULL) {
- free (message_p);
- }
- itti_receive_msg (TASK_L2L1, &message_p);
- } while (ITTI_MSG_ID(message_p) != INITIALIZE_MESSAGE);
- free (message_p);
+ if (NB_eNB_INST > 0) {
+ /* Wait for the initialize message */
+ do {
+ if (message_p != NULL) {
+ free (message_p);
+ }
+ itti_receive_msg (TASK_L2L1, &message_p);
+ } while (ITTI_MSG_ID(message_p) != INITIALIZE_MESSAGE);
+ free (message_p);
+ }
#endif
for (frame = 0; frame < oai_emulation.info.n_frames; frame++) {
@@ -869,6 +840,64 @@ void *l2l1_task(void *args_p) {
return NULL;
}
+#if defined(ENABLE_ITTI)
+static int create_tasks(void) {
+# if defined(ENABLE_USE_MME)
+ {
+ if (NB_eNB_INST > 0) {
+ if (itti_create_task(TASK_SCTP, sctp_eNB_task, NULL) < 0) {
+ LOG_E(EMU, "Create task failed");
+ LOG_D(EMU, "Initializing SCTP task interface: FAILED\n");
+ return -1;
+ }
+
+ if (itti_create_task(TASK_S1AP, s1ap_eNB_task, NULL) < 0) {
+ LOG_E(EMU, "Create task failed");
+ LOG_D(EMU, "Initializing S1AP task interface: FAILED\n");
+ return -1;
+ }
+ }
+ }
+# endif
+
+# ifdef OPENAIR2
+ {
+ if (NB_eNB_INST > 0) {
+ if (itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL) < 0) {
+ LOG_E(EMU, "Create task failed");
+ LOG_D(EMU, "Initializing RRC eNB task interface: FAILED\n");
+ exit (-1);
+ }
+ }
+
+ if (NB_UE_INST > 0) {
+ if (itti_create_task (TASK_RRC_UE, rrc_ue_task, NULL) < 0) {
+ LOG_E(EMU, "Create task failed");
+ LOG_D(EMU, "Initializing RRC UE task interface: FAILED\n");
+ exit (-1);
+ }
+ }
+ }
+# endif
+
+ if (itti_create_task(TASK_L2L1, l2l1_task, NULL) < 0) {
+ LOG_E(EMU, "Create task failed");
+ LOG_D(EMU, "Initializing L2L1 task interface: FAILED\n");
+ return -1;
+ }
+
+ if (NB_eNB_INST > 0) {
+ /* Last task to create, others task must be ready before its start */
+ if (itti_create_task(TASK_ENB_APP, eNB_app_task, NULL) < 0) {
+ LOG_E(EMU, "Create task failed");
+ LOG_D(EMU, "Initializing eNB APP task interface: FAILED\n");
+ return -1;
+ }
+ }
+ return 0;
+}
+#endif
+
Packet_OTG_List *otg_pdcp_buffer;
int main(int argc, char **argv) {
@@ -1054,10 +1083,11 @@ int main(int argc, char **argv) {
#if defined(ENABLE_ITTI)
// Handle signals until all tasks are terminated
- if (itti_create_task_successful())
+ if (create_tasks() >= 0) {
itti_wait_tasks_end();
- else
- exit(-1); // need a softer mode
+ } else {
+ exit(-1); // need a softer mode
+ }
#else
eNB_app_task(NULL); // do nothing for the moment
l2l1_task (NULL);
diff --git a/targets/SIMU/USER/oaisim.h b/targets/SIMU/USER/oaisim.h
index 5d8bb57ad3ced9d9cd52833d89148508faa7a4ce..8e96153ed3a4e34387ab04b67060196a25e76d6b 100644
--- a/targets/SIMU/USER/oaisim.h
+++ b/targets/SIMU/USER/oaisim.h
@@ -42,10 +42,6 @@ void calc_path_loss(node_desc_t* node_tx, node_desc_t* node_rx, channel_desc_t *
void do_OFDM_mod(mod_sym_t **txdataF, s32 **txdata, uint32_t frame, u16 next_slot, LTE_DL_FRAME_PARMS *frame_parms);
-#ifdef ENABLE_ITTI
-int itti_create_task_successful(void);
-void *l2l1_task(void *args_p);
-#endif
#ifdef OPENAIR2
int omv_write (int pfd, Node_list enb_node_list, Node_list ue_node_list, Data_Flow_Unit omv_data);
void omv_end (int pfd, Data_Flow_Unit omv_data);
diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c
index 60d4af8fa46ad564bc6c5700806aba3f5a570c95..ed89fde0cfe8c6dd5d9dbae2728d8fc5cd002be2 100644
--- a/targets/SIMU/USER/oaisim_functions.c
+++ b/targets/SIMU/USER/oaisim_functions.c
@@ -589,24 +589,6 @@ void init_openair2() {
s32 i;
s32 UE_id;
-#if defined(ENABLE_ITTI)
- if (NB_eNB_INST > 0) {
- if (itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL) < 0) {
- LOG_E(EMU, "Create task failed");
- LOG_D(EMU, "Initializing RRC eNB task interface: FAILED\n");
- exit (-1);
- }
- }
-
- if (NB_UE_INST > 0) {
- if (itti_create_task (TASK_RRC_UE, rrc_ue_task, NULL) < 0) {
- LOG_E(EMU, "Create task failed");
- LOG_D(EMU, "Initializing RRC UE task interface: FAILED\n");
- exit (-1);
- }
- }
-#endif
-
l2_init (&PHY_vars_eNB_g[0]->lte_frame_parms,
oai_emulation.info.eMBMS_active_state,
oai_emulation.info.cba_group_active,