From be2b2ca2bb99e567c384e42948a8116e4558724a Mon Sep 17 00:00:00 2001 From: Navid Nikaein Date: Sat, 5 Apr 2014 08:57:12 +0000 Subject: [PATCH] * catch CTRL^C in oaisim, and handle oaisim shutdown (not fully tested) * fix few pre-ci issues git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5231 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- .../collection/hashtable/obj_hashtable.h | 3 +- openair2/LAYER2/RLC/rlc_mac.c | 3 +- openair2/UTIL/OSD/OpenAirEmu.conf | 4 +- .../LTE_RAL_ENB/INCLUDE/lteRALenb_main.h | 4 +- .../LTE_RAL_UE/INCLUDE/lteRALue_main.h | 4 +- .../GENERIC-LTE-EPC/CONF/enb.sfr.sud.conf | 27 +- targets/RTAI/USER/Makefile | 3 +- targets/SIMU/USER/Makefile | 10 - targets/SIMU/USER/oaisim.c | 281 ++++++++++-------- targets/SIMU/USER/oaisim_config.c | 3 +- 10 files changed, 184 insertions(+), 158 deletions(-) diff --git a/common/utils/collection/hashtable/obj_hashtable.h b/common/utils/collection/hashtable/obj_hashtable.h index c984e1c150..1450022b52 100755 --- a/common/utils/collection/hashtable/obj_hashtable.h +++ b/common/utils/collection/hashtable/obj_hashtable.h @@ -4,7 +4,8 @@ #include #include -#include "collection/hashtable/hashtable.h" +//#include "collection/hashtable/hashtable.h" +#include "hashtable.h" typedef struct obj_hash_node_s { int key_size; diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c index eddf96f8ce..3b9644deb3 100644 --- a/openair2/LAYER2/RLC/rlc_mac.c +++ b/openair2/LAYER2/RLC/rlc_mac.c @@ -424,7 +424,8 @@ mac_rlc_status_resp_t mac_rlc_status_ind( rlc_mode = rlc_union_p->mode; } else { rlc_mode = RLC_MODE_NONE; - LOG_E(RLC , "RLC not configured rb id %u lcid %u module %u!\n", rb_id, channel_idP, ue_module_idP); + //LOG_W(RLC , "[%s] RLC not configured rb id %u lcid %u module %u!\n", __FUNCTION__, rb_id, channel_idP, ue_module_idP); + LOG_D(RLC , "[%s] RLC not configured rb id %u lcid %u module %u!\n", __FUNCTION__, rb_id, channel_idP, ue_module_idP); } switch (rlc_mode) { diff --git a/openair2/UTIL/OSD/OpenAirEmu.conf b/openair2/UTIL/OSD/OpenAirEmu.conf index 10b0ef860a..aa37b9df44 100644 --- a/openair2/UTIL/OSD/OpenAirEmu.conf +++ b/openair2/UTIL/OSD/OpenAirEmu.conf @@ -1,6 +1,6 @@ >>>>>>>>>>>>>>>>>>>>>>>>>> OAIEMU Ending <<<<<<<<<<<<<<<<<<<<<<<<<<\n\n"); - free (otg_pdcp_buffer); -#ifdef SMBV - if (config_smbv) { - smbv_send_config (smbv_fname,smbv_ip); - } -#endif - - //Perform KPI measurements - if (oai_emulation.info.otg_enabled == 1) - kpi_gen (); - - if (oai_emulation.info.opp_enabled == 1) - print_opp_meas(); - - // relase all rx state - if (ethernet_flag == 1) { - emu_transport_release (); - } - -#ifdef PROC - if (abstraction_flag == 0 && Channel_Flag==0 && Process_Flag==0) -#else - if (abstraction_flag == 0) -#endif - { - /* - #ifdef IFFT_FPGA - free(txdataF2[0]); - free(txdataF2[1]); - free(txdataF2); - free(txdata[0]); - free(txdata[1]); - free(txdata); - #endif - */ - - for (i = 0; i < 2; i++) { - free (s_re[i]); - free (s_im[i]); - free (r_re[i]); - free (r_im[i]); - } - free (s_re); - free (s_im); - free (r_re); - free (r_im); - - lte_sync_time_free (); - } - // pthread_join(sigth, NULL); - - // added for PHY abstraction - if (oai_emulation.info.ocm_enabled == 1) { - for (eNB_inst = 0; eNB_inst < NUMBER_OF_eNB_MAX; eNB_inst++) { - free (enb_data[eNB_inst]); - } - for (UE_inst = 0; UE_inst < NUMBER_OF_UE_MAX; UE_inst++) { - free (ue_data[UE_inst]); - } - } //End of PHY abstraction changes - -#ifdef OPENAIR2 - mac_top_cleanup (); -#endif - - // stop OMG - stop_mobility_generator (oai_emulation.info.omg_model_ue); //omg_param_list.mobility_type -#ifdef OPENAIR2 - if (oai_emulation.info.omv_enabled == 1) - omv_end (pfd[1], omv_data); -#endif - if ((oai_emulation.info.ocm_enabled == 1) && (ethernet_flag == 0) && (ShaF != NULL)) - destroyMat (ShaF, map1, map2); - - if ((oai_emulation.info.opt_enabled == 1)) - terminate_opt (); - - if (oai_emulation.info.cli_enabled) - cli_server_cleanup (); - - //bring oai if down - terminate (); - log_thread_finalize (); - logClean (); - vcd_signal_dumper_close (); + raise(SIGINT); + oai_shutdown(); return (0); } @@ -1444,38 +1373,138 @@ void print_opp_meas(void){ } -/* + static void *sigh(void *arg) { - int signum; - sigset_t sigcatch; - sigemptyset(&sigcatch); - sigaddset(&sigcatch, SIGHUP); - sigaddset(&sigcatch, SIGINT); - sigaddset(&sigcatch, SIGTERM); + int signum; + sigset_t sigcatch; + sigemptyset(&sigcatch); + sigaddset(&sigcatch, SIGHUP); + sigaddset(&sigcatch, SIGINT); + sigaddset(&sigcatch, SIGTERM); + sigaddset(&sigcatch, SIGQUIT); + + for (;;) { + sigwait(&sigcatch, &signum); + //sigwait(&sigblock, &signum); + switch (signum) { + case SIGHUP: + case SIGINT: + case SIGTERM: + case SIGQUIT: + fprintf(stderr,"received signal %d \n", signum); + // no need for mutx: when ITTI not used, this variable is only accessed by this function + l2l1_state = L2L1_TERMINATED; + break; + default: + fprintf(stderr,"Unexpected signal %d \n",signum); + exit(-1); + break; + } + } + pthread_exit(NULL); + } - for (;;) { - sigwait(&sigcatch, &signum); - switch (signum) { - case SIGHUP: - case SIGINT: - case SIGTERM: - terminate(); - default: - break; - } - } - pthread_exit(NULL); - } - */ -void terminate(void) { +void oai_shutdown(void) { + static int done=0; int i; char interfaceName[8]; + + if (done) + return; + + free (otg_pdcp_buffer); + +#ifdef SMBV + if (config_smbv) { + smbv_send_config (smbv_fname,smbv_ip); + } +#endif + + //Perform KPI measurements + if (oai_emulation.info.otg_enabled == 1) + kpi_gen (); + + if (oai_emulation.info.opp_enabled == 1) + print_opp_meas(); + + // relase all rx state + if (ethernet_flag == 1) { + emu_transport_release (); + } + +#ifdef PROC + if (abstraction_flag == 0 && Channel_Flag==0 && Process_Flag==0) +#else + if (abstraction_flag == 0) +#endif + { + /* + #ifdef IFFT_FPGA + free(txdataF2[0]); + free(txdataF2[1]); + free(txdataF2); + free(txdata[0]); + free(txdata[1]); + free(txdata); + #endif + */ + + for (i = 0; i < 2; i++) { + free (s_re[i]); + free (s_im[i]); + free (r_re[i]); + free (r_im[i]); + } + free (s_re); + free (s_im); + free (r_re); + free (r_im); + + lte_sync_time_free (); + } + + // added for PHY abstraction + if (oai_emulation.info.ocm_enabled == 1) { + for (eNB_inst = 0; eNB_inst < NUMBER_OF_eNB_MAX; eNB_inst++) { + free (enb_data[eNB_inst]); + } + for (UE_inst = 0; UE_inst < NUMBER_OF_UE_MAX; UE_inst++) { + free (ue_data[UE_inst]); + } + } //End of PHY abstraction changes + +#ifdef OPENAIR2 + mac_top_cleanup (); +#endif + + // stop OMG + stop_mobility_generator (oai_emulation.info.omg_model_ue); //omg_param_list.mobility_type +#ifdef OPENAIR2 + if (oai_emulation.info.omv_enabled == 1) + omv_end (pfd[1], omv_data); +#endif + if ((oai_emulation.info.ocm_enabled == 1) && (ethernet_flag == 0) && (ShaF != NULL)) + destroyMat (ShaF, map1, map2); + + if ((oai_emulation.info.opt_enabled == 1)) + terminate_opt (); + + if (oai_emulation.info.cli_enabled) + cli_server_cleanup (); + for (i = 0; i < NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX; i++) if (oai_emulation.info.oai_ifup[i] == 1) { - sprintf (interfaceName, "oai%d", i); - bringInterfaceUp (interfaceName, 0); + sprintf (interfaceName, "oai%d", i); + bringInterfaceUp (interfaceName, 0); } + + log_thread_finalize (); + logClean (); + vcd_signal_dumper_close (); + done =1; + + LOG_N(EMU, ">>>>>>>>>>>>>>>>>>>>>>>>>>> OAIEMU shutdown <<<<<<<<<<<<<<<<<<<<<<<<<<\n\n"); } diff --git a/targets/SIMU/USER/oaisim_config.c b/targets/SIMU/USER/oaisim_config.c index de2dce38ff..94eb752e1f 100644 --- a/targets/SIMU/USER/oaisim_config.c +++ b/targets/SIMU/USER/oaisim_config.c @@ -460,7 +460,7 @@ int olg_config() { oai_emulation.info.g_log_verbosity, oai_emulation.emulation_config.log_emu.interval ); - + /* // if perf eval then reset the otg log level set_comp_log(PHY, LOG_EMERG, 0x15,1); set_comp_log(EMU, LOG_EMERG, 0x15,1); @@ -473,6 +473,7 @@ int olg_config() { set_comp_log(PDCP, LOG_DEBUG, LOG_MED,1); set_comp_log(RLC, LOG_DEBUG, LOG_MED,1); set_comp_log(RRC, LOG_DEBUG, LOG_MED,1); + */ #if defined(ENABLE_RAL) set_comp_log(RAL_ENB, LOG_TRACE, LOG_MED,1); set_comp_log(RAL_UE, LOG_TRACE, LOG_MED,1);