FlexRAN: reimplement timers without ITTI
The timer code used to trigger periodic statistics message sending used ITTI. Together with a high frequency reporting (e.g. 1ms), this resulted in high CPU usage. This commit reimplements this: * using a thread that is synchronized to the RU (if there is no MAC, we assume there is no RU generating a tick so we create the tick source ourselves) * no RB trees but plain arrays * smaller interface for users * slight user interface changes * remove stopped timer state: such timer might be simply removed * remove one-shot timers
This commit is contained in:
@@ -26,100 +26,45 @@
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#ifndef _FLEXRAN_AGENT_TIMER_
|
||||
#define _FLEXRAN_AGENT_TIMER_
|
||||
|
||||
#include "flexran_agent_common.h"
|
||||
#include "flexran_agent_common_internal.h"
|
||||
#include "flexran_agent_extern.h"
|
||||
#include "flexran_agent_defs.h"
|
||||
|
||||
|
||||
# include "tree.h"
|
||||
# include "intertask_interface.h"
|
||||
|
||||
|
||||
|
||||
/*******************
|
||||
* timer primitves
|
||||
*******************/
|
||||
|
||||
#define TIMER_NULL -1
|
||||
#define TIMER_TYPE_INVALIDE -2
|
||||
#define TIMER_SETUP_FAILED -3
|
||||
#define TIMER_REMOVED_FAILED -4
|
||||
#define TIMER_ELEMENT_NOT_FOUND -5
|
||||
|
||||
typedef enum {
|
||||
FLEXRAN_AGENT_TIMER_TYPE_ONESHOT,
|
||||
FLEXRAN_AGENT_TIMER_TYPE_PERIODIC,
|
||||
} flexran_agent_timer_type_t;
|
||||
|
||||
/* Type of the callback executed when the timer expired */
|
||||
typedef Protocol__FlexranMessage *(*flexran_agent_timer_callback_t)(void*);
|
||||
typedef Protocol__FlexranMessage *(*flexran_agent_timer_callback_t)(
|
||||
mid_t mod_id, const Protocol__FlexranMessage *msg);
|
||||
|
||||
err_code_t flexran_agent_timer_init(mid_t mod_id);
|
||||
void flexran_agent_timer_exit(mid_t mod_id);
|
||||
|
||||
typedef struct flexran_agent_timer_args_s{
|
||||
mid_t mod_id;
|
||||
Protocol__FlexranMessage *msg;
|
||||
} flexran_agent_timer_args_t;
|
||||
|
||||
|
||||
typedef struct flexran_agent_timer_element_s{
|
||||
RB_ENTRY(flexran_agent_timer_element_s) entry;
|
||||
|
||||
agent_id_t agent_id;
|
||||
instance_t instance;
|
||||
|
||||
flexran_agent_timer_type_t type;
|
||||
flexran_agent_timer_state_t state;
|
||||
|
||||
uint32_t interval_sec;
|
||||
uint32_t interval_usec;
|
||||
|
||||
long timer_id; /* Timer id returned by the timer API*/
|
||||
xid_t xid; /*The id of the task as received by the controller
|
||||
message*/
|
||||
|
||||
flexran_agent_timer_callback_t cb;
|
||||
flexran_agent_timer_args_t *timer_args;
|
||||
|
||||
} flexran_agent_timer_element_t;
|
||||
|
||||
typedef struct flexran_agent_timer_instance_s{
|
||||
RB_HEAD(flexran_agent_map, flexran_agent_timer_element_s) flexran_agent_head;
|
||||
}flexran_agent_timer_instance_t;
|
||||
|
||||
|
||||
err_code_t flexran_agent_init_timer(void);
|
||||
/* Signals next subframe for FlexRAN timers */
|
||||
void flexran_agent_timer_signal(mid_t mod_id);
|
||||
|
||||
/* Create a timer for some agent related event with id xid. */
|
||||
err_code_t flexran_agent_create_timer(mid_t mod_id,
|
||||
uint32_t sf,
|
||||
uint32_t timer_type,
|
||||
flexran_agent_timer_type_t timer_type,
|
||||
xid_t xid,
|
||||
flexran_agent_timer_callback_t cb,
|
||||
void *timer_args);
|
||||
Protocol__FlexranMessage *msg);
|
||||
|
||||
/* Destroy all existing timers */
|
||||
err_code_t flexran_agent_destroy_timers(void);
|
||||
|
||||
/* Destroy the timer with the given timer_id */
|
||||
err_code_t flexran_agent_destroy_timer(long timer_id);
|
||||
err_code_t flexran_agent_destroy_timers(mid_t mod_id);
|
||||
|
||||
/* Destroy the timer for task with id xid */
|
||||
err_code_t flexran_agent_destroy_timer_by_task_id(xid_t xid);
|
||||
err_code_t flexran_agent_destroy_timer(mid_t mod_id, xid_t xid);
|
||||
|
||||
/* Stop a timer */
|
||||
err_code_t flexran_agent_stop_timer(long timer_id);
|
||||
|
||||
/* Restart the given timer */
|
||||
err_code_t flexran_agent_restart_timer(long *timer_id);
|
||||
|
||||
/* Find the timer with the given timer_id */
|
||||
struct flexran_agent_timer_element_s * get_timer_entry(long timer_id);
|
||||
|
||||
/* Obtain the protocol message stored in the given expired timer */
|
||||
Protocol__FlexranMessage * flexran_agent_process_timeout(long timer_id, void* timer_args);
|
||||
|
||||
/* Comparator function comparing two timers. Decides the ordering of the timers */
|
||||
int flexran_agent_compare_timer(struct flexran_agent_timer_element_s *a, struct flexran_agent_timer_element_s *b);
|
||||
|
||||
/* RB_PROTOTYPE is for .h files */
|
||||
RB_PROTOTYPE(flexran_agent_map, flexran_agent_timer_element_s, entry, flexran_agent_compare_timer);
|
||||
#endif /* _FLEXRAN_AGENT_TIMER_ */
|
||||
|
||||
Reference in New Issue
Block a user