Commit 6102fa4b authored by Cedric Roux's avatar Cedric Roux

- Fix some performances issues for softmodem

- Remove eventfd if task has only polling mode
- Created dummy thread to convert eventfd from RT thread to non RT threads
- Added eNB app to softmodem
- Set poll mode for itti dumper thread in softmodem
- Disable timers for softmodem

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4545 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 18f113c4
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#ifdef RTAI
# include <rtai_fifos.h>
#endif
#include "queue.h" #include "queue.h"
#include "assertions.h" #include "assertions.h"
...@@ -49,6 +53,10 @@ ...@@ -49,6 +53,10 @@
#include "intertask_interface.h" #include "intertask_interface.h"
#include "intertask_interface_dump.h" #include "intertask_interface_dump.h"
#if defined(OAI_EMU) || defined(RTAI)
# include "vcd_signal_dumper.h"
#endif
/* Includes "intertask_interface_init.h" to check prototype coherence, but /* Includes "intertask_interface_init.h" to check prototype coherence, but
* disable threads and messages information generation. * disable threads and messages information generation.
*/ */
...@@ -62,10 +70,18 @@ ...@@ -62,10 +70,18 @@
const int itti_debug = 0; const int itti_debug = 0;
const int itti_debug_poll = 0; const int itti_debug_poll = 0;
#define ITTI_DEBUG(x, args...) do { if (itti_debug) fprintf(stdout, "[ITTI][D]"x, ##args); fflush (stdout); } \ /* Don't flush if using RTAI */
#ifdef RTAI
# define ITTI_DEBUG(x, args...) do { if (itti_debug) rt_printk("[ITTI][D]"x, ##args); } \
while(0)
# define ITTI_ERROR(x, args...) do { rt_printk("[ITTI][E]"x, ##args); } \
while(0)
#else
# define ITTI_DEBUG(x, args...) do { if (itti_debug) fprintf(stdout, "[ITTI][D]"x, ##args); fflush (stdout); } \
while(0) while(0)
#define ITTI_ERROR(x, args...) do { fprintf(stdout, "[ITTI][E]"x, ##args); fflush (stdout); } \ # define ITTI_ERROR(x, args...) do { fprintf(stdout, "[ITTI][E]"x, ##args); fflush (stdout); } \
while(0) while(0)
#endif
/* Global message size */ /* Global message size */
#define MESSAGE_SIZE(mESSAGEiD) (sizeof(MessageHeader) + itti_desc.messages_info[mESSAGEiD].size) #define MESSAGE_SIZE(mESSAGEiD) (sizeof(MessageHeader) + itti_desc.messages_info[mESSAGEiD].size)
...@@ -89,6 +105,7 @@ typedef struct message_list_s { ...@@ -89,6 +105,7 @@ typedef struct message_list_s {
typedef struct thread_desc_s { typedef struct thread_desc_s {
/* pthread associated with the thread */ /* pthread associated with the thread */
pthread_t task_thread; pthread_t task_thread;
/* State of the thread */ /* State of the thread */
volatile task_state_t task_state; volatile task_state_t task_state;
} thread_desc_t; } thread_desc_t;
...@@ -266,6 +283,7 @@ inline MessageDef *itti_alloc_new_message(task_id_t origin_task_id, MessagesIds ...@@ -266,6 +283,7 @@ inline MessageDef *itti_alloc_new_message(task_id_t origin_task_id, MessagesIds
int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *message) int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *message)
{ {
thread_id_t thread_id = TASK_GET_THREAD_ID(task_id); thread_id_t thread_id = TASK_GET_THREAD_ID(task_id);
thread_id_t origin_task_id;
message_list_t *new; message_list_t *new;
uint32_t priority; uint32_t priority;
message_number_t message_number; message_number_t message_number;
...@@ -281,14 +299,32 @@ int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *me ...@@ -281,14 +299,32 @@ int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *me
message_id = message->ittiMsgHeader.messageId; message_id = message->ittiMsgHeader.messageId;
DevCheck(message_id < itti_desc.messages_id_max, itti_desc.messages_id_max, message_id, 0); DevCheck(message_id < itti_desc.messages_id_max, itti_desc.messages_id_max, message_id, 0);
origin_task_id = ITTI_MSG_ORIGIN_ID(message);
#if defined(OAI_EMU) || defined(RTAI)
vcd_signal_dumper_dump_variable_by_name(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_SEND_MSG,
task_id);
#endif
priority = itti_get_message_priority (message_id); priority = itti_get_message_priority (message_id);
/* Increment the global message number */ /* Increment the global message number */
message_number = itti_increment_message_number (); message_number = itti_increment_message_number ();
#ifdef RTAI
if (pthread_self() != itti_desc.threads[TASK_GET_THREAD_ID(origin_task_id)].task_thread)
#endif
itti_dump_queue_message (message_number, message, itti_desc.messages_info[message_id].name, itti_dump_queue_message (message_number, message, itti_desc.messages_info[message_id].name,
sizeof(MessageHeader) + message->ittiMsgHeader.ittiMsgSize); sizeof(MessageHeader) + message->ittiMsgHeader.ittiMsgSize);
ITTI_DEBUG("Message %s, number %lu with priority %d successfully sent from %s to queue (%u:%s)\n",
itti_desc.messages_info[message_id].name,
message_number,
priority,
itti_get_task_name(origin_task_id),
task_id,
itti_get_task_name(task_id));
if (task_id != TASK_UNKNOWN) if (task_id != TASK_UNKNOWN)
{ {
/* We cannot send a message if the task is not running */ /* We cannot send a message if the task is not running */
...@@ -314,6 +350,19 @@ int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *me ...@@ -314,6 +350,19 @@ int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *me
new->message_priority = priority; new->message_priority = priority;
#if defined(ENABLE_EVENT_FD) #if defined(ENABLE_EVENT_FD)
# ifdef RTAI
if ((pthread_self() != itti_desc.threads[TASK_GET_THREAD_ID(origin_task_id)].task_thread) &&
(TASK_GET_PARENT_TASK_ID(origin_task_id) != TASK_UNKNOWN))
{
/* This is the RT task, -> enqueue in the parent thread */
lfds611_queue_enqueue(itti_desc.tasks[TASK_GET_PARENT_TASK_ID(origin_task_id)].message_queue, new);
/* Signal from RT thread */
// rtf_sem_post(56);
} else
# endif
/* No need to use a event fd for subtasks */
if (TASK_GET_PARENT_TASK_ID(task_id) == TASK_UNKNOWN)
{ {
ssize_t write_ret; ssize_t write_ret;
uint64_t sem_counter = 1; uint64_t sem_counter = 1;
...@@ -322,7 +371,9 @@ int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *me ...@@ -322,7 +371,9 @@ int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *me
/* Call to write for an event fd must be of 8 bytes */ /* Call to write for an event fd must be of 8 bytes */
write_ret = write(itti_desc.tasks[task_id].task_event_fd, &sem_counter, sizeof(sem_counter)); write_ret = write(itti_desc.tasks[task_id].task_event_fd, &sem_counter, sizeof(sem_counter));
DevCheck(write_ret == sizeof(sem_counter), write_ret, sem_counter, 0); DevCheck(write_ret == sizeof(sem_counter), write_ret, sem_counter, task_id);
} else {
lfds611_queue_enqueue(itti_desc.tasks[task_id].message_queue, new);
} }
#else #else
if (STAILQ_EMPTY (&itti_desc.tasks[task_id].message_queue)) { if (STAILQ_EMPTY (&itti_desc.tasks[task_id].message_queue)) {
...@@ -365,9 +416,11 @@ int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *me ...@@ -365,9 +416,11 @@ int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *me
#endif #endif
} }
ITTI_DEBUG( #if defined(OAI_EMU) || defined(RTAI)
"Message %s, number %lu with priority %d successfully sent to queue (%u:%s)\n", vcd_signal_dumper_dump_variable_by_name(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_SEND_MSG_END,
itti_desc.messages_info[message_id].name, message_number, priority, task_id, itti_get_task_name(task_id)); task_id);
#endif
return 0; return 0;
} }
...@@ -499,6 +552,10 @@ static inline void itti_receive_msg_internal_event_fd(task_id_t task_id, uint8_t ...@@ -499,6 +552,10 @@ static inline void itti_receive_msg_internal_event_fd(task_id_t task_id, uint8_t
void itti_receive_msg(task_id_t task_id, MessageDef **received_msg) void itti_receive_msg(task_id_t task_id, MessageDef **received_msg)
{ {
#if defined(OAI_EMU) || defined(RTAI)
vcd_signal_dumper_dump_variable_by_name(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_RECV_MSG,
task_id);
#endif
#if defined(ENABLE_EVENT_FD) #if defined(ENABLE_EVENT_FD)
itti_receive_msg_internal_event_fd(task_id, 0, received_msg); itti_receive_msg_internal_event_fd(task_id, 0, received_msg);
#else #else
...@@ -531,6 +588,10 @@ void itti_receive_msg(task_id_t task_id, MessageDef **received_msg) ...@@ -531,6 +588,10 @@ void itti_receive_msg(task_id_t task_id, MessageDef **received_msg)
// Release the mutex // Release the mutex
pthread_mutex_unlock (&itti_desc.tasks[task_id].message_queue_mutex); pthread_mutex_unlock (&itti_desc.tasks[task_id].message_queue_mutex);
#endif #endif
#if defined(OAI_EMU) || defined(RTAI)
vcd_signal_dumper_dump_variable_by_name(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_RECV_MSG_END,
task_id);
#endif
} }
void itti_poll_msg(task_id_t task_id, MessageDef **received_msg) { void itti_poll_msg(task_id_t task_id, MessageDef **received_msg) {
...@@ -539,8 +600,21 @@ void itti_poll_msg(task_id_t task_id, MessageDef **received_msg) { ...@@ -539,8 +600,21 @@ void itti_poll_msg(task_id_t task_id, MessageDef **received_msg) {
*received_msg = NULL; *received_msg = NULL;
#if defined(OAI_EMU) || defined(RTAI)
vcd_signal_dumper_dump_variable_by_name(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_POLL_MSG,
task_id);
#endif
#if defined(ENABLE_EVENT_FD) #if defined(ENABLE_EVENT_FD)
itti_receive_msg_internal_event_fd(task_id, 1, received_msg); {
struct message_list_s *message;
if (lfds611_queue_dequeue (itti_desc.tasks[task_id].message_queue, (void **) &message) == 1)
{
*received_msg = message->msg;
free (message);
}
}
#else #else
if (itti_desc.tasks[task_id].message_in_queue != 0) { if (itti_desc.tasks[task_id].message_in_queue != 0) {
message_list_t *temp; message_list_t *temp;
...@@ -572,6 +646,11 @@ void itti_poll_msg(task_id_t task_id, MessageDef **received_msg) { ...@@ -572,6 +646,11 @@ void itti_poll_msg(task_id_t task_id, MessageDef **received_msg) {
if ((itti_debug_poll) && (*received_msg == NULL)) { if ((itti_debug_poll) && (*received_msg == NULL)) {
ITTI_DEBUG("No message in queue[(%u:%s)]\n", task_id, itti_get_task_name(task_id)); ITTI_DEBUG("No message in queue[(%u:%s)]\n", task_id, itti_get_task_name(task_id));
} }
#if defined(OAI_EMU) || defined(RTAI)
vcd_signal_dumper_dump_variable_by_name(VCD_SIGNAL_DUMPER_VARIABLE_ITTI_POLL_MSG_END,
task_id);
#endif
} }
int itti_create_task(task_id_t task_id, void *(*start_routine)(void *), void *args_p) { int itti_create_task(task_id_t task_id, void *(*start_routine)(void *), void *args_p) {
...@@ -596,15 +675,28 @@ int itti_create_task(task_id_t task_id, void *(*start_routine)(void *), void *ar ...@@ -596,15 +675,28 @@ int itti_create_task(task_id_t task_id, void *(*start_routine)(void *), void *ar
return 0; return 0;
} }
void itti_mark_task_ready(task_id_t task_id) { void itti_mark_task_ready(task_id_t task_id)
{
thread_id_t thread_id = TASK_GET_THREAD_ID(task_id); thread_id_t thread_id = TASK_GET_THREAD_ID(task_id);
DevCheck(thread_id < itti_desc.thread_max, thread_id, itti_desc.thread_max, 0); DevCheck(thread_id < itti_desc.thread_max, thread_id, itti_desc.thread_max, 0);
#ifdef RTAI
/* Assign low priority to created threads */
{
struct sched_param sched_param;
sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO) + 1;
sched_setscheduler(0, SCHED_FIFO, &sched_param);
}
#endif
/* Register the thread in itti dump */ /* Register the thread in itti dump */
itti_dump_thread_use_ring_buffer(); itti_dump_thread_use_ring_buffer();
#if !defined(ENABLE_EVENT_FD) #if defined(ENABLE_EVENT_FD)
/* Mark the thread as using LFDS queue */
lfds611_queue_use(itti_desc.tasks[task_id].message_queue);
#else
// Lock the mutex to get exclusive access to the list // Lock the mutex to get exclusive access to the list
pthread_mutex_lock (&itti_desc.tasks[task_id].message_queue_mutex); pthread_mutex_lock (&itti_desc.tasks[task_id].message_queue_mutex);
#endif #endif
...@@ -636,6 +728,8 @@ int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_i ...@@ -636,6 +728,8 @@ int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_i
const message_info_t *messages_info, const char * const messages_definition_xml, const char * const dump_file_name) { const message_info_t *messages_info, const char * const messages_definition_xml, const char * const dump_file_name) {
task_id_t task_id; task_id_t task_id;
thread_id_t thread_id; thread_id_t thread_id;
int ret;
itti_desc.message_number = 1; itti_desc.message_number = 1;
ITTI_DEBUG("Init: %d tasks, %d threads, %d messages\n", task_max, thread_max, messages_id_max); ITTI_DEBUG("Init: %d tasks, %d threads, %d messages\n", task_max, thread_max, messages_id_max);
...@@ -664,14 +758,30 @@ int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_i ...@@ -664,14 +758,30 @@ int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_i
/* Initializing each queue and related stuff */ /* Initializing each queue and related stuff */
for (task_id = TASK_FIRST; task_id < itti_desc.task_max; task_id++) for (task_id = TASK_FIRST; task_id < itti_desc.task_max; task_id++)
{ {
ITTI_DEBUG("Initializing %stask %s%s%s\n",
itti_desc.tasks_info[task_id].parent_task != TASK_UNKNOWN ? "sub-" : "",
itti_desc.tasks_info[task_id].name,
itti_desc.tasks_info[task_id].parent_task != TASK_UNKNOWN ? " with parent " : "",
itti_desc.tasks_info[task_id].parent_task != TASK_UNKNOWN ?
itti_get_task_name(itti_desc.tasks_info[task_id].parent_task) : "");
#if defined(ENABLE_EVENT_FD) #if defined(ENABLE_EVENT_FD)
ITTI_DEBUG("Creating queue of message of size %u\n", itti_desc.tasks_info[task_id].queue_size); ITTI_DEBUG("Creating queue of message of size %u\n", itti_desc.tasks_info[task_id].queue_size);
if (lfds611_queue_new(&itti_desc.tasks[task_id].message_queue, itti_desc.tasks_info[task_id].queue_size) < 0)
ret = lfds611_queue_new(&itti_desc.tasks[task_id].message_queue, itti_desc.tasks_info[task_id].queue_size);
if (ret < 0)
{ {
ITTI_ERROR("lfds611_queue_new failed for task %u\n", task_id); ITTI_ERROR("lfds611_queue_new failed for task %u\n", task_id);
DevAssert(0 == 1); DevAssert(0 == 1);
} }
# ifdef RTAI
if (task_id == TASK_L2L1)
{
ret = rtf_sem_init(56, 0);
}
# endif
itti_desc.tasks[task_id].epoll_fd = epoll_create1(0); itti_desc.tasks[task_id].epoll_fd = epoll_create1(0);
if (itti_desc.tasks[task_id].epoll_fd == -1) { if (itti_desc.tasks[task_id].epoll_fd == -1) {
ITTI_ERROR("Failed to create new epoll fd: %s\n", strerror(errno)); ITTI_ERROR("Failed to create new epoll fd: %s\n", strerror(errno));
...@@ -689,7 +799,7 @@ int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_i ...@@ -689,7 +799,7 @@ int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_i
itti_desc.tasks[task_id].nb_events = 1; itti_desc.tasks[task_id].nb_events = 1;
itti_desc.tasks[task_id].events = malloc(sizeof(struct epoll_event)); itti_desc.tasks[task_id].events = calloc(1, sizeof(struct epoll_event));
itti_desc.tasks[task_id].events->events = EPOLLIN | EPOLLERR; itti_desc.tasks[task_id].events->events = EPOLLIN | EPOLLERR;
itti_desc.tasks[task_id].events->data.fd = itti_desc.tasks[task_id].task_event_fd; itti_desc.tasks[task_id].events->data.fd = itti_desc.tasks[task_id].task_event_fd;
...@@ -725,7 +835,9 @@ int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_i ...@@ -725,7 +835,9 @@ int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_i
itti_dump_init (messages_definition_xml, dump_file_name); itti_dump_init (messages_definition_xml, dump_file_name);
#ifndef RTAI
CHECK_INIT_RETURN(timer_init ()); CHECK_INIT_RETURN(timer_init ());
#endif
return 0; return 0;
} }
......
...@@ -38,6 +38,10 @@ ...@@ -38,6 +38,10 @@
# include <sys/epoll.h> # include <sys/epoll.h>
#endif #endif
#ifdef RTAI
# include <rtai_sem.h>
#endif
#ifndef INTERTASK_INTERFACE_H_ #ifndef INTERTASK_INTERFACE_H_
#define INTERTASK_INTERFACE_H_ #define INTERTASK_INTERFACE_H_
...@@ -91,6 +95,7 @@ typedef enum task_priorities_e { ...@@ -91,6 +95,7 @@ typedef enum task_priorities_e {
typedef struct task_info_s { typedef struct task_info_s {
thread_id_t thread; thread_id_t thread;
task_id_t parent_task;
task_priorities_t priority; task_priorities_t priority;
unsigned int queue_size; unsigned int queue_size;
/* Printable name */ /* Printable name */
......
...@@ -58,14 +58,25 @@ ...@@ -58,14 +58,25 @@
#include "intertask_interface.h" #include "intertask_interface.h"
#include "intertask_interface_dump.h" #include "intertask_interface_dump.h"
#if defined(RTAI)
#include "vcd_signal_dumper.h"
#endif
#define SIGNAL_NAME_LENGTH 48 #define SIGNAL_NAME_LENGTH 48
static const int itti_dump_debug = 0; static const int itti_dump_debug = 0;
#define ITTI_DUMP_DEBUG(x, args...) do { if (itti_dump_debug) fprintf(stdout, "[ITTI][D]"x, ##args); } \ #ifdef RTAI
# define ITTI_DUMP_DEBUG(x, args...) do { if (itti_dump_debug) rt_printk("[ITTI][D]"x, ##args); } \
while(0)
# define ITTI_DUMP_ERROR(x, args...) do { rt_printk("[ITTI][E]"x, ##args); } \
while(0) while(0)
#define ITTI_DUMP_ERROR(x, args...) do { fprintf(stdout, "[ITTI][E]"x, ##args); } \ #else
# define ITTI_DUMP_DEBUG(x, args...) do { if (itti_dump_debug) fprintf(stdout, "[ITTI][D]"x, ##args); } \
while(0) while(0)
# define ITTI_DUMP_ERROR(x, args...) do { fprintf(stdout, "[ITTI][E]"x, ##args); } \
while(0)
#endif
/* Message sent is an intertask dump type */ /* Message sent is an intertask dump type */
#define ITTI_DUMP_MESSAGE_TYPE 0x1 #define ITTI_DUMP_MESSAGE_TYPE 0x1
...@@ -100,12 +111,14 @@ typedef struct itti_desc_s { ...@@ -100,12 +111,14 @@ typedef struct itti_desc_s {
*/ */
struct lfds611_ringbuffer_state *itti_message_queue; struct lfds611_ringbuffer_state *itti_message_queue;
uint32_t queue_size;
int nb_connected; int nb_connected;
#ifndef RTAI
/* Event fd used to notify new messages (semaphore) */ /* Event fd used to notify new messages (semaphore) */
int event_fd; int event_fd;
#else
unsigned long messages_in_queue __attribute__((aligned(8)));
#endif
int itti_listen_socket; int itti_listen_socket;
...@@ -247,13 +260,14 @@ static int itti_dump_send_xml_definition(const int sd, const char *message_defin ...@@ -247,13 +260,14 @@ static int itti_dump_send_xml_definition(const int sd, const char *message_defin
static int itti_dump_enqueue_message(itti_dump_queue_item_t *new, uint32_t message_size, static int itti_dump_enqueue_message(itti_dump_queue_item_t *new, uint32_t message_size,
uint32_t message_type) uint32_t message_type)
{ {
ssize_t write_ret;
uint64_t sem_counter = 1;
struct lfds611_freelist_element *new_queue_element = NULL; struct lfds611_freelist_element *new_queue_element = NULL;
DevAssert(new != NULL); DevAssert(new != NULL);
#if defined(RTAI)
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_ITTI_DUMP_ENQUEUE_MESSAGE, VCD_FUNCTION_IN);
#endif
new->message_type = message_type; new->message_type = message_type;
new->message_size = message_size; new->message_size = message_size;
...@@ -265,9 +279,22 @@ static int itti_dump_enqueue_message(itti_dump_queue_item_t *new, uint32_t messa ...@@ -265,9 +279,22 @@ static int itti_dump_enqueue_message(itti_dump_queue_item_t *new, uint32_t messa
lfds611_ringbuffer_put_write_element(itti_dump_queue.itti_message_queue, lfds611_ringbuffer_put_write_element(itti_dump_queue.itti_message_queue,
new_queue_element); new_queue_element);
#ifdef RTAI
__sync_fetch_and_add (&itti_dump_queue.messages_in_queue, 1);
#else
{
ssize_t write_ret;
uint64_t sem_counter = 1;
/* Call to write for an event fd must be of 8 bytes */ /* Call to write for an event fd must be of 8 bytes */
write_ret = write(itti_dump_queue.event_fd, &sem_counter, sizeof(sem_counter)); write_ret = write(itti_dump_queue.event_fd, &sem_counter, sizeof(sem_counter));
DevCheck(write_ret == sizeof(sem_counter), write_ret, sem_counter, 0); DevCheck(write_ret == sizeof(sem_counter), write_ret, sem_counter, 0);
}
#endif
#if defined(RTAI)
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_ITTI_DUMP_ENQUEUE_MESSAGE, VCD_FUNCTION_OUT);
#endif
return 0; return 0;
} }
...@@ -281,7 +308,6 @@ int itti_dump_queue_message(message_number_t message_number, ...@@ -281,7 +308,6 @@ int itti_dump_queue_message(message_number_t message_number,
{ {
itti_dump_queue_item_t *new; itti_dump_queue_item_t *new;
size_t message_name_length; size_t message_name_length;
int i;
DevAssert(message_name != NULL); DevAssert(message_name != NULL);
DevAssert(message_p != NULL); DevAssert(message_p != NULL);
...@@ -311,15 +337,71 @@ int itti_dump_queue_message(message_number_t message_number, ...@@ -311,15 +337,71 @@ int itti_dump_queue_message(message_number_t message_number,
memcpy(new->message_name, message_name, message_name_length); memcpy(new->message_name, message_name, message_name_length);
itti_dump_enqueue_message(new, message_size, ITTI_DUMP_MESSAGE_TYPE); itti_dump_enqueue_message(new, message_size, ITTI_DUMP_MESSAGE_TYPE);
}
for (i = 0; i < ITTI_DUMP_MAX_CON; i++) { return 0;
if (itti_dump_queue.itti_clients[i].sd == -1) }
continue;
itti_dump_send_message(itti_dump_queue.itti_clients[i].sd, new); static void itti_dump_flush_ring_buffer(int flush_all)
{
struct lfds611_freelist_element *element = NULL;
void *user_data;
int j;
#ifdef RTAI
unsigned long number_of_messages;
number_of_messages = itti_dump_queue.messages_in_queue;
ITTI_DUMP_DEBUG("%lu elements in queue\n", number_of_messages);
if (number_of_messages == 0) {
return;
} }
__sync_sub_and_fetch(&itti_dump_queue.messages_in_queue, number_of_messages);
#endif
do {
/* Acquire the ring element */
lfds611_ringbuffer_get_read_element(itti_dump_queue.itti_message_queue, &element);
DevAssert(element != NULL);
/* Retrieve user part of the message */
lfds611_freelist_get_user_data_from_element(element, &user_data);
if (((itti_dump_queue_item_t *)user_data)->message_type == ITTI_DUMP_EXIT_SIGNAL)
{
#ifndef RTAI
close(itti_dump_queue.event_fd);
#endif
close(itti_dump_queue.itti_listen_socket);
lfds611_ringbuffer_put_read_element(itti_dump_queue.itti_message_queue, element);
/* Leave the thread as we detected end signal */
pthread_exit(NULL);
} }
return 0; /* Write message to file */
itti_dump_fwrite_message((itti_dump_queue_item_t *)user_data);
/* Send message to remote analyzer */
for (j = 0; j < ITTI_DUMP_MAX_CON; j++) {
if (itti_dump_queue.itti_clients[j].sd > 0) {
itti_dump_send_message(itti_dump_queue.itti_clients[j].sd,
(itti_dump_queue_item_t *)user_data);
}
}
/* We have finished with this element, reinsert it in the ring buffer */
lfds611_ringbuffer_put_read_element(itti_dump_queue.itti_message_queue, element);
} while(flush_all
#ifdef RTAI
&& --number_of_messages
#endif
);
} }
static void *itti_dump_socket(void *arg_p) static void *itti_dump_socket(void *arg_p)
...@@ -332,6 +414,11 @@ static void *itti_dump_socket(void *arg_p) ...@@ -332,6 +414,11 @@ static void *itti_dump_socket(void *arg_p)
fd_set read_set, working_set; fd_set read_set, working_set;
struct sockaddr_in servaddr; /* socket address structure */ struct sockaddr_in servaddr; /* socket address structure */
struct timeval *timeout_p = NULL;
#ifdef RTAI
struct timeval timeout;
#endif
ITTI_DUMP_DEBUG("Creating TCP dump socket on port %u\n", ITTI_PORT); ITTI_DUMP_DEBUG("Creating TCP dump socket on port %u\n", ITTI_PORT);
message_definition_xml = (char *)arg_p; message_definition_xml = (char *)arg_p;
...@@ -383,11 +470,15 @@ static void *itti_dump_socket(void *arg_p) ...@@ -383,11 +470,15 @@ static void *itti_dump_socket(void *arg_p)
/* Add the listener */ /* Add the listener */
FD_SET(itti_listen_socket, &read_set); FD_SET(itti_listen_socket, &read_set);
#ifndef RTAI
/* Add the event fd */ /* Add the event fd */
FD_SET(itti_dump_queue.event_fd, &read_set); FD_SET(itti_dump_queue.event_fd, &read_set);
/* Max of both sd */ /* Max of both sd */
max_sd = itti_listen_socket > itti_dump_queue.event_fd ? itti_listen_socket : itti_dump_queue.event_fd; max_sd = itti_listen_socket > itti_dump_queue.event_fd ? itti_listen_socket : itti_dump_queue.event_fd;
#else
max_sd = itti_listen_socket;
#endif
itti_dump_queue.itti_listen_socket = itti_listen_socket; itti_dump_queue.itti_listen_socket = itti_listen_socket;
...@@ -400,15 +491,26 @@ static void *itti_dump_socket(void *arg_p) ...@@ -400,15 +491,26 @@ static void *itti_dump_socket(void *arg_p)
int i; int i;
memcpy(&working_set, &read_set, sizeof(read_set)); memcpy(&working_set, &read_set, sizeof(read_set));
#ifdef RTAI
timeout.tv_sec = 0;
timeout.tv_usec = 100000;
timeout_p = &timeout;
#else
timeout_p = NULL;
#endif
/* No timeout: select blocks till a new event has to be handled /* No timeout: select blocks till a new event has to be handled
* on sd's. * on sd's.
*/ */
rc = select(max_sd + 1, &working_set, NULL, NULL, NULL); rc = select(max_sd + 1, &working_set, NULL, NULL, timeout_p);
if (rc < 0) { if (rc < 0) {
ITTI_DUMP_ERROR("select failed (%d:%s)\n", errno, strerror(errno)); ITTI_DUMP_ERROR("select failed (%d:%s)\n", errno, strerror(errno));
pthread_exit(NULL); pthread_exit(NULL);
} else if (rc == 0) {
/* Timeout */
itti_dump_flush_ring_buffer(1);
} }
desc_ready = rc; desc_ready = rc;
...@@ -418,14 +520,11 @@ static void *itti_dump_socket(void *arg_p) ...@@ -418,14 +520,11 @@ static void *itti_dump_socket(void *arg_p)
{ {
desc_ready -= 1; desc_ready -= 1;
#ifndef RTAI
if (i == itti_dump_queue.event_fd) { if (i == itti_dump_queue.event_fd) {
/* Notification of new element to dump from other tasks */ /* Notification of new element to dump from other tasks */
uint64_t sem_counter; uint64_t sem_counter;
ssize_t read_ret; ssize_t read_ret;
void *user_data;
int j;
struct lfds611_freelist_element *element;
/* Read will always return 1 */ /* Read will always return 1 */
read_ret = read (itti_dump_queue.event_fd, &sem_counter, sizeof(sem_counter)); read_ret = read (itti_dump_queue.event_fd, &sem_counter, sizeof(sem_counter));
...@@ -435,41 +534,12 @@ static void *itti_dump_socket(void *arg_p) ...@@ -435,41 +534,12 @@ static void *itti_dump_socket(void *arg_p)
} }
DevCheck(read_ret == sizeof(sem_counter), read_ret, sizeof(sem_counter), 0); DevCheck(read_ret == sizeof(sem_counter), read_ret, sizeof(sem_counter), 0);
/* Acquire the ring element */ itti_dump_flush_ring_buffer(0);
lfds611_ringbuffer_get_read_element(itti_dump_queue.itti_message_queue, &element);
DevAssert(element != NULL);
/* Retrieve user part of the message */
lfds611_freelist_get_user_data_from_element(element, &user_data);
if (((itti_dump_queue_item_t *)user_data)->message_type == ITTI_DUMP_EXIT_SIGNAL)
{
close(itti_dump_queue.event_fd);
close(itti_dump_queue.itti_listen_socket);
lfds611_ringbuffer_put_read_element(itti_dump_queue.itti_message_queue, element);
/* Leave the thread as we detected end signal */
pthread_exit(NULL);
}
/* Write message to file */
itti_dump_fwrite_message((itti_dump_queue_item_t *)user_data);
/* Send message to remote analyzer */
for (j = 0; j < ITTI_DUMP_MAX_CON; j++) {
if (itti_dump_queue.itti_clients[i].sd > 0) {
itti_dump_send_message(itti_dump_queue.itti_clients[i].sd,
(itti_dump_queue_item_t *)user_data);
}
}
/* We have finished with this element, reinsert it in the ring buffer */
lfds611_ringbuffer_put_read_element(itti_dump_queue.itti_message_queue, element);
ITTI_DUMP_DEBUG("Write element to file\n"); ITTI_DUMP_DEBUG("Write element to file\n");
} else if (i == itti_listen_socket) { } else
#endif
if (i == itti_listen_socket) {
do { do {
client_socket = accept(itti_listen_socket, NULL, NULL); client_socket = accept(itti_listen_socket, NULL, NULL);
if (client_socket < 0) { if (client_socket < 0) {
...@@ -581,11 +651,6 @@ int itti_dump_handle_new_connection(int sd, const char *xml_definition, uint32_t ...@@ -581,11 +651,6 @@ int itti_dump_handle_new_connection(int sd, const char *xml_definition, uint32_t
return 0; return 0;
} }
int itti_dump_user_data_init_function(void **user_data, void *user_state)
{
return 0;
}
/* This function should be called by each thread that will use the ring buffer */ /* This function should be called by each thread that will use the ring buffer */
void itti_dump_thread_use_ring_buffer(void) void itti_dump_thread_use_ring_buffer(void)
{ {
...@@ -597,7 +662,7 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons ...@@ -597,7 +662,7 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons
int i, ret; int i, ret;
struct sched_param scheduler_param; struct sched_param scheduler_param;
scheduler_param.sched_priority = 10; scheduler_param.sched_priority = sched_get_priority_min(SCHED_FIFO) + 1;
if (dump_file_name != NULL) if (dump_file_name != NULL)
{ {
...@@ -637,6 +702,9 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons ...@@ -637,6 +702,9 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons
DevAssert(0 == 1); DevAssert(0 == 1);
} }
#ifdef RTAI
itti_dump_queue.messages_in_queue = 0;
#else
itti_dump_queue.event_fd = eventfd(0, EFD_SEMAPHORE); itti_dump_queue.event_fd = eventfd(0, EFD_SEMAPHORE);
if (itti_dump_queue.event_fd == -1) if (itti_dump_queue.event_fd == -1)
{ {
...@@ -644,8 +712,8 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons ...@@ -644,8 +712,8 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons
/* Always assert on this condition */ /* Always assert on this condition */
DevAssert(0 == 1); DevAssert(0 == 1);
} }
#endif
itti_dump_queue.queue_size = 0;
itti_dump_queue.nb_connected = 0; itti_dump_queue.nb_connected = 0;
for(i = 0; i < ITTI_DUMP_MAX_CON; i++) { for(i = 0; i < ITTI_DUMP_MAX_CON; i++) {
...@@ -660,7 +728,7 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons ...@@ -660,7 +728,7 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons
DevAssert(0 == 1); DevAssert(0 == 1);
} }
ret = pthread_attr_setschedpolicy(&itti_dump_queue.attr, SCHED_RR); ret = pthread_attr_setschedpolicy(&itti_dump_queue.attr, SCHED_FIFO);
if (ret < 0) { if (ret < 0) {
ITTI_DUMP_ERROR("pthread_attr_setschedpolicy (SCHED_IDLE) failed (%d:%s)\n", errno, strerror(errno)); ITTI_DUMP_ERROR("pthread_attr_setschedpolicy (SCHED_IDLE) failed (%d:%s)\n", errno, strerror(errno));
DevAssert(0 == 1); DevAssert(0 == 1);
...@@ -681,7 +749,7 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons ...@@ -681,7 +749,7 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons
return 0; return 0;
} }
void itti_dump_user_data_delete_function(void *user_data, void *user_state) static void itti_dump_user_data_delete_function(void *user_data, void *user_state)
{ {
if (user_data != NULL) if (user_data != NULL)
{ {
......
...@@ -56,9 +56,9 @@ const char * const messages_definition_xml = { ...@@ -56,9 +56,9 @@ const char * const messages_definition_xml = {
/* Map task id to printable name. */ /* Map task id to printable name. */
const task_info_t tasks_info[] = { const task_info_t tasks_info[] = {
{0, 0, 0, "TASK_UNKNOWN"}, {0, TASK_UNKNOWN, 0, 0, "TASK_UNKNOWN"},
#define TASK_DEF(tHREADiD, pRIO, qUEUEsIZE) { tHREADiD##_THREAD, pRIO, qUEUEsIZE, #tHREADiD }, #define TASK_DEF(tHREADiD, pRIO, qUEUEsIZE) { tHREADiD##_THREAD, TASK_UNKNOWN, pRIO, qUEUEsIZE, #tHREADiD },
#define SUB_TASK_DEF(tHREADiD, sUBtASKiD, qUEUEsIZE) { sUBtASKiD##_THREAD, 0, qUEUEsIZE, #sUBtASKiD }, #define SUB_TASK_DEF(tHREADiD, sUBtASKiD, qUEUEsIZE) { sUBtASKiD##_THREAD, tHREADiD##_THREAD, 0, qUEUEsIZE, #sUBtASKiD },
#include <tasks_def.h> #include <tasks_def.h>
#undef SUB_TASK_DEF #undef SUB_TASK_DEF
#undef TASK_DEF #undef TASK_DEF
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
/* Defines to extract task ID fields */ /* Defines to extract task ID fields */
#define TASK_GET_THREAD_ID(tASKiD) (itti_desc.tasks_info[tASKiD].thread) #define TASK_GET_THREAD_ID(tASKiD) (itti_desc.tasks_info[tASKiD].thread)
#define TASK_GET_PARENT_TASK_ID(tASKiD) (itti_desc.tasks_info[tASKiD].parent_task)
/* Extract the instance from a message */ /* Extract the instance from a message */
#define ITTI_MESSAGE_GET_INSTANCE(mESSAGE) ((mESSAGE)->ittiMsgHeader.instance) #define ITTI_MESSAGE_GET_INSTANCE(mESSAGE) ((mESSAGE)->ittiMsgHeader.instance)
......
...@@ -80,6 +80,7 @@ do { \ ...@@ -80,6 +80,7 @@ do { \
int timer_handle_signal(siginfo_t *info) int timer_handle_signal(siginfo_t *info)
{ {
#if !defined(RTAI)
struct timer_elm_s *timer_p; struct timer_elm_s *timer_p;
MessageDef *message_p; MessageDef *message_p;
timer_has_expired_t *timer_expired_p; timer_has_expired_t *timer_expired_p;
...@@ -121,6 +122,7 @@ int timer_handle_signal(siginfo_t *info) ...@@ -121,6 +122,7 @@ int timer_handle_signal(siginfo_t *info)
free(message_p); free(message_p);
return -1; return -1;
} }
#endif
return 0; return 0;
} }
...@@ -134,6 +136,7 @@ int timer_setup( ...@@ -134,6 +136,7 @@ int timer_setup(
void *timer_arg, void *timer_arg,
long *timer_id) long *timer_id)
{ {
#if !defined(RTAI)
struct sigevent se; struct sigevent se;
struct itimerspec its; struct itimerspec its;
struct timer_elm_s *timer_p; struct timer_elm_s *timer_p;
...@@ -201,14 +204,16 @@ int timer_setup( ...@@ -201,14 +204,16 @@ int timer_setup(
pthread_mutex_lock(&timer_desc.timer_list_mutex); pthread_mutex_lock(&timer_desc.timer_list_mutex);
STAILQ_INSERT_TAIL(&timer_desc.timer_queue, timer_p, entries); STAILQ_INSERT_TAIL(&timer_desc.timer_queue, timer_p, entries);
pthread_mutex_unlock(&timer_desc.timer_list_mutex); pthread_mutex_unlock(&timer_desc.timer_list_mutex);
#endif
return 0; return 0;
} }
int timer_remove(long timer_id) int timer_remove(long timer_id)
{ {
struct timer_elm_s *timer_p;
int rc = 0; int rc = 0;
#if !defined(RTAI)
struct timer_elm_s *timer_p;
TMR_DEBUG("Removing timer 0x%lx\n", timer_id); TMR_DEBUG("Removing timer 0x%lx\n", timer_id);
...@@ -231,6 +236,7 @@ int timer_remove(long timer_id) ...@@ -231,6 +236,7 @@ int timer_remove(long timer_id)
} }
free(timer_p); free(timer_p);
timer_p = NULL; timer_p = NULL;
#endif
return rc; return rc;
} }
......
...@@ -4,7 +4,7 @@ TASK_DEF(TASK_TIMER, TASK_PRIORITY_MAX, 10) ...@@ -4,7 +4,7 @@ TASK_DEF(TASK_TIMER, TASK_PRIORITY_MAX, 10)
// Other possible tasks in the process // Other possible tasks in the process
/// Layer 2 and Layer 1 task supporting all the synchronous processing /// Layer 2 and Layer 1 task supporting all the synchronous processing
TASK_DEF(TASK_L2L1, TASK_PRIORITY_MAX_LEAST, 10) TASK_DEF(TASK_L2L1, TASK_PRIORITY_MAX_LEAST, 1000)
//// Layer 2 and Layer 1 sub-tasks //// Layer 2 and Layer 1 sub-tasks
SUB_TASK_DEF(TASK_L2L1, TASK_PDCP_UE, 200) SUB_TASK_DEF(TASK_L2L1, TASK_PDCP_UE, 200)
SUB_TASK_DEF(TASK_L2L1, TASK_PDCP_ENB, 200) SUB_TASK_DEF(TASK_L2L1, TASK_PDCP_ENB, 200)
......
...@@ -79,7 +79,13 @@ const char* eurecomVariablesNames[] = { ...@@ -79,7 +79,13 @@ const char* eurecomVariablesNames[] = {
"frame_number", "frame_number",
"slot_number", "slot_number",
"daq_mbox", "daq_mbox",
"diff2" "diff2",
"itti_send_msg",
"itti_send_msg_end",
"itti_poll_msg",
"itti_poll_msg_end",
"itti_recv_msg",
"itti_recv_msg_end"
}; };
const char* eurecomFunctionsNames[] = { const char* eurecomFunctionsNames[] = {
...@@ -154,6 +160,7 @@ const char* eurecomFunctionsNames[] = { ...@@ -154,6 +160,7 @@ const char* eurecomFunctionsNames[] = {
"phy_eNB_dlsch_scramblig", "phy_eNB_dlsch_scramblig",
"pdcp_apply_security", "pdcp_apply_security",
"pdcp_validate_security", "pdcp_validate_security",
"itti_dump_enqueue_message",
"test" "test"
}; };
......
...@@ -49,6 +49,12 @@ typedef enum ...@@ -49,6 +49,12 @@ typedef enum
VCD_SIGNAL_DUMPER_VARIABLES_SLOT_NUMBER, VCD_SIGNAL_DUMPER_VARIABLES_SLOT_NUMBER,
VCD_SIGNAL_DUMPER_VARIABLES_DAQ_MBOX, VCD_SIGNAL_DUMPER_VARIABLES_DAQ_MBOX,
VCD_SIGNAL_DUMPER_VARIABLES_DIFF, VCD_SIGNAL_DUMPER_VARIABLES_DIFF,
VCD_SIGNAL_DUMPER_VARIABLE_ITTI_SEND_MSG,
VCD_SIGNAL_DUMPER_VARIABLE_ITTI_SEND_MSG_END,
VCD_SIGNAL_DUMPER_VARIABLE_ITTI_POLL_MSG,
VCD_SIGNAL_DUMPER_VARIABLE_ITTI_POLL_MSG_END,
VCD_SIGNAL_DUMPER_VARIABLE_ITTI_RECV_MSG,
VCD_SIGNAL_DUMPER_VARIABLE_ITTI_RECV_MSG_END,
VCD_SIGNAL_DUMPER_VARIABLES_LAST, VCD_SIGNAL_DUMPER_VARIABLES_LAST,
VCD_SIGNAL_DUMPER_VARIABLES_END = VCD_SIGNAL_DUMPER_VARIABLES_LAST, VCD_SIGNAL_DUMPER_VARIABLES_END = VCD_SIGNAL_DUMPER_VARIABLES_LAST,
} vcd_signal_dump_variables; } vcd_signal_dump_variables;
...@@ -126,6 +132,7 @@ typedef enum ...@@ -126,6 +132,7 @@ typedef enum
VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_SCRAMBLING, VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_SCRAMBLING,
VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_APPLY_SECURITY, VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_APPLY_SECURITY,
VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_VALIDATE_SECURITY, VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_VALIDATE_SECURITY,
VCD_SIGNAL_DUMPER_FUNCTIONS_ITTI_DUMP_ENQUEUE_MESSAGE,
VCD_SIGNAL_DUMPER_FUNCTIONS_TEST, VCD_SIGNAL_DUMPER_FUNCTIONS_TEST,
VCD_SIGNAL_DUMPER_FUNCTIONS_LAST, VCD_SIGNAL_DUMPER_FUNCTIONS_LAST,
VCD_SIGNAL_DUMPER_FUNCTIONS_END = VCD_SIGNAL_DUMPER_FUNCTIONS_LAST, VCD_SIGNAL_DUMPER_FUNCTIONS_END = VCD_SIGNAL_DUMPER_FUNCTIONS_LAST,
......
...@@ -98,7 +98,7 @@ CFLAGS += -DOPENAIR2 -DNO_RRM -DPUCCH -DMAC_CONTEXT=1 ...@@ -98,7 +98,7 @@ CFLAGS += -DOPENAIR2 -DNO_RRM -DPUCCH -DMAC_CONTEXT=1
endif endif
ifdef ENABLE_ITTI ifdef ENABLE_ITTI
OBJ += $(UTILS_OBJS) RTAI_OBJ += $(UTILS_OBJS)
endif endif
CFLAGS += $(L2_incl) $(UTIL_incl) $(UTILS_incl) CFLAGS += $(L2_incl) $(UTIL_incl) $(UTILS_incl)
...@@ -174,6 +174,12 @@ $(LFDS_LIB): ...@@ -174,6 +174,12 @@ $(LFDS_LIB):
$(RTAI_OBJ): %.o : %.c $(RTAI_OBJ): %.o : %.c
@echo Compiling $< ... @echo Compiling $< ...
@$(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) $(RTAI_CFLAGS) -o $@ $< @$(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) $(RTAI_CFLAGS) -o $@ $<
@$(CC) -MM $(CFLAGS) $(EXTRA_CFLAGS) $(RTAI_CFLAGS) $< > $*.d
@mv -f $*.d $*.d.tmp
@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
@rm -f $*.d.tmp
ifdef ENABLE_ITTI ifdef ENABLE_ITTI
$(OBJ) $(RTAI_OBJ): $(ITTI_MESSAGES_H) $(OBJ) $(RTAI_OBJ): $(ITTI_MESSAGES_H)
...@@ -201,7 +207,7 @@ synctest: $(OBJ) $(ASN1_MSG_OBJS1) $(RTAI_OBJ) ...@@ -201,7 +207,7 @@ synctest: $(OBJ) $(ASN1_MSG_OBJS1) $(RTAI_OBJ)
lte-softmodem: $(OBJ) $(ASN1_MSG_OBJS1) $(RTAI_OBJ) $(SHARED_DEPENDENCIES) lte-softmodem: $(OBJ) $(ASN1_MSG_OBJS1) $(RTAI_OBJ) $(SHARED_DEPENDENCIES)
@echo Linking $@ @echo Linking $@
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(OBJ) $(RTAI_OBJ) $(ASN1_MSG_OBJS1) -o lte-softmodem $(LDFLAGS) $(LIBS) @$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(OBJ) $(RTAI_OBJ) $(ASN1_MSG_OBJS1) -o lte-softmodem $(LDFLAGS) $(LIBS)
lte-softmodem-usrp: $(OBJ) $(ASN1_MSG_OBJS1) $(RTAI_OBJ) $(USRP_OBJ) $(SHARED_DEPENDENCIES) lte-softmodem-usrp: $(OBJ) $(ASN1_MSG_OBJS1) $(RTAI_OBJ) $(USRP_OBJ) $(SHARED_DEPENDENCIES)
@echo Linking $@ @echo Linking $@
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include <getopt.h> #include <getopt.h>
#include "rt_wrapper.h" #include "rt_wrapper.h"
#include "assertions.h"
#ifdef EMOS #ifdef EMOS
#include <gps.h> #include <gps.h>
...@@ -148,7 +149,7 @@ exmimo_config_t *p_exmimo_config; ...@@ -148,7 +149,7 @@ exmimo_config_t *p_exmimo_config;
exmimo_id_t *p_exmimo_id; exmimo_id_t *p_exmimo_id;
volatile unsigned int *DAQ_MBOX; volatile unsigned int *DAQ_MBOX;
int oai_exit = 0; volatile int oai_exit = 0;
//int time_offset[4] = {-138,-138,-138,-138}; //int time_offset[4] = {-138,-138,-138,-138};
//int time_offset[4] = {-145,-145,-145,-145}; //int time_offset[4] = {-145,-145,-145,-145};
...@@ -456,6 +457,32 @@ void *emos_thread (void *arg) ...@@ -456,6 +457,32 @@ void *emos_thread (void *arg)
} }
#endif #endif
#if defined(ENABLE_ITTI)
void *dummy_l2l1_task(void *arg)
{
ssize_t ret = 0;
MessageDef *received_msg;
itti_mark_task_ready(TASK_L2L1);
while (!oai_exit)
{
usleep(100);
do {
itti_poll_msg(TASK_L2L1, &received_msg);
if (received_msg != NULL) {
itti_send_msg_to_task(ITTI_MSG_DESTINATION_ID(received_msg),
ITTI_MSG_INSTANCE(received_msg),
received_msg);
}
} while(received_msg != NULL);
}
return NULL;
}
#endif
/* This is the main eNB thread. It gets woken up by the kernel driver using the RTAI message mechanism (rt_send and rt_receive). */ /* This is the main eNB thread. It gets woken up by the kernel driver using the RTAI message mechanism (rt_send and rt_receive). */
static void *eNB_thread(void *arg) static void *eNB_thread(void *arg)
{ {
...@@ -510,8 +537,12 @@ static void *eNB_thread(void *arg) ...@@ -510,8 +537,12 @@ static void *eNB_thread(void *arg)
// at the eNB, even slots have double as much time since most of the processing is done here and almost nothing in odd slots // at the eNB, even slots have double as much time since most of the processing is done here and almost nothing in odd slots
LOG_D(HW,"eNB Frame %d, time %llu: missed slot, proceeding with next one (slot %d, hw_slot %d, diff %d)\n",frame, rt_get_time_ns(), slot, hw_slot, diff); LOG_D(HW,"eNB Frame %d, time %llu: missed slot, proceeding with next one (slot %d, hw_slot %d, diff %d)\n",frame, rt_get_time_ns(), slot, hw_slot, diff);
slot++; slot++;
if (frame>0) if (frame>0) {
oai_exit=1; oai_exit=1;
#if defined(ENABLE_ITTI)
itti_send_terminate_message(TASK_L2L1);
#endif
}
if (slot==20){ if (slot==20){
slot=0; slot=0;
frame++; frame++;
...@@ -915,17 +946,10 @@ static void *UE_thread(void *arg) ...@@ -915,17 +946,10 @@ static void *UE_thread(void *arg)
return 0; return 0;
} }
/* DUmmy l2l1 task */ void *eNB_app_task(void *args_p)
void *l2l1_task(void *args_p) { {
#if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)
#if defined(ENABLE_ITTI)
MessageDef *message_p; MessageDef *message_p;
itti_mark_task_ready (TASK_L2L1);
# if defined(ENABLE_USE_MME)
/* Trying to register each eNB */
{
char *mme_address_v4; char *mme_address_v4;
char *mme_address_v6 = "2001:660:5502:12:30da:829a:2343:b6cf"; char *mme_address_v6 = "2001:660:5502:12:30da:829a:2343:b6cf";
s1ap_register_eNB_t *s1ap_register_eNB; s1ap_register_eNB_t *s1ap_register_eNB;
...@@ -941,7 +965,7 @@ void *l2l1_task(void *args_p) { ...@@ -941,7 +965,7 @@ void *l2l1_task(void *args_p) {
} }
/* FIXME: following parameters should be setup by eNB applicative layer ? */ /* FIXME: following parameters should be setup by eNB applicative layer ? */
message_p = itti_alloc_new_message(TASK_L2L1, S1AP_REGISTER_ENB); message_p = itti_alloc_new_message(TASK_ENB_APP, S1AP_REGISTER_ENB);
s1ap_register_eNB = &message_p->ittiMsg.s1ap_register_eNB; s1ap_register_eNB = &message_p->ittiMsg.s1ap_register_eNB;
...@@ -963,14 +987,12 @@ void *l2l1_task(void *args_p) { ...@@ -963,14 +987,12 @@ void *l2l1_task(void *args_p) {
strlen(mme_address_v6)); strlen(mme_address_v6));
itti_send_msg_to_task(TASK_S1AP, eNB_id, message_p); itti_send_msg_to_task(TASK_S1AP, eNB_id, message_p);
}
# endif
#endif
#if defined(ENABLE_ITTI) itti_mark_task_ready (TASK_ENB_APP); // at the end of init for the current task
while (1) {
do {
// Checks if a message has been sent to L2L1 task // Checks if a message has been sent to L2L1 task
itti_receive_msg (TASK_L2L1, &message_p); itti_receive_msg (TASK_ENB_APP, &message_p);
if (message_p != NULL) { if (message_p != NULL) {
switch (ITTI_MSG_ID(message_p)) { switch (ITTI_MSG_ID(message_p)) {
...@@ -989,7 +1011,7 @@ void *l2l1_task(void *args_p) { ...@@ -989,7 +1011,7 @@ void *l2l1_task(void *args_p) {
free (message_p); free (message_p);
} }
} } while(1);
#endif #endif
return NULL; return NULL;
...@@ -1205,6 +1227,13 @@ int main(int argc, char **argv) { ...@@ -1205,6 +1227,13 @@ int main(int argc, char **argv) {
// initialize the log (see log.h for details) // initialize the log (see log.h for details)
logInit(); logInit();
if (ouput_vcd) {
if (UE_flag==1)
vcd_signal_dumper_init("/tmp/openair_dump_UE.vcd");
else
vcd_signal_dumper_init("/tmp/openair_dump_eNB.vcd");
}
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file); itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file);
...@@ -1219,9 +1248,14 @@ int main(int argc, char **argv) { ...@@ -1219,9 +1248,14 @@ int main(int argc, char **argv) {
LOG_D(EMU, "Initializing S1AP task interface: FAILED\n"); LOG_D(EMU, "Initializing S1AP task interface: FAILED\n");
return -1; return -1;
} }
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;
}
# endif # endif
if (itti_create_task(TASK_L2L1, l2l1_task, NULL) < 0) { if (itti_create_task(TASK_L2L1, dummy_l2l1_task, NULL) < 0) {
LOG_E(EMU, "Create task failed"); LOG_E(EMU, "Create task failed");
LOG_D(EMU, "Initializing L2L1 task interface: FAILED\n"); LOG_D(EMU, "Initializing L2L1 task interface: FAILED\n");
return -1; return -1;
...@@ -1231,13 +1265,6 @@ int main(int argc, char **argv) { ...@@ -1231,13 +1265,6 @@ int main(int argc, char **argv) {
// itti_wait_tasks_end(); // itti_wait_tasks_end();
#endif #endif
if (ouput_vcd) {
if (UE_flag==1)
vcd_signal_dumper_init("/tmp/openair_dump_UE.vcd");
else
vcd_signal_dumper_init("/tmp/openair_dump_eNB.vcd");
}
#ifdef NAS_NETLINK #ifdef NAS_NETLINK
netlink_init(); netlink_init();
#endif #endif
...@@ -1419,7 +1446,12 @@ int main(int argc, char **argv) { ...@@ -1419,7 +1446,12 @@ int main(int argc, char **argv) {
g_log->log_component[OTG].flag = LOG_HIGH; g_log->log_component[OTG].flag = LOG_HIGH;
g_log->log_component[RRC].level = LOG_INFO; g_log->log_component[RRC].level = LOG_INFO;
g_log->log_component[RRC].flag = LOG_HIGH; g_log->log_component[RRC].flag = LOG_HIGH;
#if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)
g_log->log_component[S1AP].level = LOG_INFO;
g_log->log_component[S1AP].flag = LOG_HIGH;
g_log->log_component[SCTP].level = LOG_INFO;
g_log->log_component[SCTP].flag = LOG_HIGH;
#endif
PHY_vars_eNB_g = malloc(sizeof(PHY_VARS_eNB*)); PHY_vars_eNB_g = malloc(sizeof(PHY_VARS_eNB*));
PHY_vars_eNB_g[0] = init_lte_eNB(frame_parms,eNB_id,Nid_cell,cooperation_flag,transmission_mode,abstraction_flag); PHY_vars_eNB_g[0] = init_lte_eNB(frame_parms,eNB_id,Nid_cell,cooperation_flag,transmission_mode,abstraction_flag);
......
...@@ -485,10 +485,9 @@ void *eNB_app_task(void *args_p) { ...@@ -485,10 +485,9 @@ void *eNB_app_task(void *args_p) {
} while(1); } while(1);
itti_terminate_tasks(TASK_ENB_APP); itti_terminate_tasks(TASK_ENB_APP);
#endif
return NULL; return NULL;
#endif
return NULL;
} }
void *l2l1_task(void *args_p) { void *l2l1_task(void *args_p) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment