diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 2ca7dc54f03c6b445d18f4cb81ce590e09b1879a..2b982a957c04eeb86c62ac7e900d96c067dd1cf6 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -552,6 +552,8 @@ int sinr_dB=-20; } + init_slot_isr(); + t = clock(); for (frame=0; frame<oai_emulation.info.n_frames; frame++) { @@ -606,6 +608,8 @@ int for (slot=0 ; slot<20 ; slot++) { + wait_for_slot_isr(); + last_slot = (slot - 1)%20; if (last_slot <0) last_slot+=20; diff --git a/targets/SIMU/USER/oaisim_config.c b/targets/SIMU/USER/oaisim_config.c index ece42c4313cc9c5b42a2d726cd88da52646b5bab..c913bcbaaa0307be049f143c4ef7b945ddb8a895 100644 --- a/targets/SIMU/USER/oaisim_config.c +++ b/targets/SIMU/USER/oaisim_config.c @@ -327,6 +327,9 @@ void init_oai_emulation() { oai_emulation.info.cli_num_enb= NUMBER_OF_eNB_MAX; oai_emulation.info.cli_num_ue= NUMBER_OF_UE_MAX; + + oai_emulation.info.slot_isr = 0; + oai_emulation.info.slot_sfd = -1; //for (i=0; i < oai_emulation.info.cli_num_enb; i++) for (i=0; i < NUMBER_OF_eNB_MAX; i++) diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c index da517ad5f08f1c50bd7952484e1c59f8ac122bf8..be3d9e1b3ace1500ad48507a32ac1ddf887561cc 100644 --- a/targets/SIMU/USER/oaisim_functions.c +++ b/targets/SIMU/USER/oaisim_functions.c @@ -1,4 +1,11 @@ +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> +#include <signal.h> #include <execinfo.h> +#include <time.h> + +#include <sys/timerfd.h> #include "oaisim_functions.h" @@ -102,7 +109,7 @@ void get_simulation_options(int argc, char *argv[]) { {NULL, 0, NULL, 0} }; - while ((c = getopt_long (argc, argv, "aA:b:B:c:C:D:d:eE:f:FGg:hi:IJ:k:l:m:M:n:N:O:p:P:rR:s:S:t:T:u:U:vVx:y:w:W:X:z:Z:", long_options, &option_index)) != -1) { + while ((c = getopt_long (argc, argv, "aA:b:B:c:C:D:d:eE:f:FGg:hi:IJ:k:l:m:M:n:N:oO:p:P:rR:s:S:t:T:u:U:vVx:y:w:W:X:z:Z:", long_options, &option_index)) != -1) { switch (c) { case 0: @@ -347,6 +354,9 @@ void get_simulation_options(int argc, char *argv[]) { printf("You enabled MME mode without MME support...\n"); #endif break; + case 'o': + oai_emulation.info.slot_isr = 1; + break; default: help (); exit (-1); @@ -853,6 +863,49 @@ void update_otg_UE(int module_id, unsigned int ctime) { #endif } +int init_slot_isr(void) +{ + if (oai_emulation.info.slot_isr) { + struct itimerspec its; + + int sfd; + + sfd = timerfd_create(CLOCK_REALTIME, 0); + if (sfd == -1) { + LOG_E(EMU, "Failed in timerfd_create (%d:%s)\n", errno, strerror(errno)); + exit(EXIT_FAILURE); + } + + /* Start the timer */ + its.it_value.tv_sec = 0; + its.it_value.tv_nsec = 500 * 1000; + its.it_interval.tv_sec = its.it_value.tv_sec; + its.it_interval.tv_nsec = its.it_value.tv_nsec; + + if (timerfd_settime(sfd, TFD_TIMER_ABSTIME, &its, NULL) == -1) { + LOG_E(EMU, "Failed in timer_settime (%d:%s)\n", errno, strerror(errno)); + exit(EXIT_FAILURE); + } + + oai_emulation.info.slot_sfd = sfd; + } +} + +void wait_for_slot_isr(void) +{ + uint64_t exp; + ssize_t res; + + if (oai_emulation.info.slot_sfd > 0) { + res = read(oai_emulation.info.slot_sfd, &exp, sizeof(exp)); + + if ((res < 0) || (res != sizeof(exp))) { + LOG_E(EMU, "Failed in read (%d:%s)\n", errno, strerror(errno)); + exit(EXIT_FAILURE); + } + } +} + void exit_fun(const char* s) { void *array[10]; diff --git a/targets/SIMU/USER/oaisim_functions.h b/targets/SIMU/USER/oaisim_functions.h index c28bf480bbb14f979e278ed592b1a7ed25729dae..9592f3a58d649787d4ba25e0426265d7f341d7bf 100644 --- a/targets/SIMU/USER/oaisim_functions.h +++ b/targets/SIMU/USER/oaisim_functions.h @@ -5,6 +5,9 @@ #include "UTIL/FIFO/pad_list.h" +#ifndef OAISIM_FUNCTIONS_H_ +#define OAISIM_FUNCTIONS_H_ + void get_simulation_options(int argc, char *argv[]); void check_and_adjust_params(); @@ -35,3 +38,8 @@ void exit_fun(const char* s); void init_pad(); +int init_slot_isr(void); + +void wait_for_slot_isr(void); + +#endif /* OAISIM_FUNCTIONS_H_ */