enb_agent_common.h 6.27 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/*******************************************************************************
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom

    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.


    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with OpenAirInterface.The full GNU General Public License is
   included in this distribution in the file called "COPYING". If not,
   see <http://www.gnu.org/licenses/>.

  Contact Information
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr

  Address      : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.

 *******************************************************************************/

30 31 32
/*! \file enb_agent_common.h
 * \brief common message primitves and utilities 
 * \author Navid Nikaein and Xenofon Foukas
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
 * \date 2016
 * \version 0.1
 */



#ifndef ENB_AGENT_COMMON_H_
#define ENB_AGENT_COMMON_H_


#include "header.pb-c.h"
#include "progran.pb-c.h"
#include "stats_messages.pb-c.h"
#include "stats_common.pb-c.h"

48 49 50 51 52 53 54 55 56
# include "enb_agent_defs.h"

#include "LAYER2/MAC/extern.h"
#include "LAYER2/RLC/rlc.h"

# include "tree.h"
# include "intertask_interface.h"
# include "timer.h"

57 58 59
#define PROGRAN_VERSION 0

typedef int (*enb_agent_message_decoded_callback)(
60
	mid_t mod_id,
61
       	const void *params,
62
	Protocol__ProgranMessage **msg
63 64 65 66
);

typedef int (*enb_agent_message_destruction_callback)(
	Protocol__ProgranMessage *msg
67 68 69 70 71
);

int enb_agent_serialize_message(Protocol__ProgranMessage *msg, void **buf, int *size);
int enb_agent_deserialize_message(void *data, int size, Protocol__ProgranMessage **msg);

72
int prp_create_header(xid_t xid, Protocol__PrpType type, Protocol__PrpHeader **header);
73

74
int enb_agent_hello(mid_t mod_id, const void *params, Protocol__ProgranMessage **msg);
75 76
int enb_agent_destroy_hello(Protocol__ProgranMessage *msg);

77
int enb_agent_echo_request(mid_t mod_id, const void *params, Protocol__ProgranMessage **msg);
78 79
int enb_agent_destroy_echo_request(Protocol__ProgranMessage *msg);

80
int enb_agent_echo_reply(mid_t mod_id, const void *params, Protocol__ProgranMessage **msg);
81 82 83
int enb_agent_destroy_echo_reply(Protocol__ProgranMessage *msg);


84
Protocol__ProgranMessage* enb_agent_handle_message (mid_t mod_id, 
85 86 87
						    uint8_t *data, 
						    uint32_t size);

88
void * enb_agent_send_message(Protocol__ProgranMessage *msg, 
89 90 91
			      uint32_t * size);


92 93 94 95 96 97 98 99 100 101 102 103




/****************************
 * get generic info from RAN
 ****************************/

void set_enb_vars(mid_t mod_id, ran_name_t ran);

int get_current_time_ms (mid_t mod_id, int subframe_flag);

104 105 106 107
int get_current_frame(mid_t mod_id);

int get_current_subframe(mid_t mod_id);

108 109 110 111
/*Return the frame and subframe number in compact 16-bit format.
  Bits 0-3 frame, rest for subframe. Required by progRAN protocol*/
uint16_t get_sfn_sf (mid_t mod_id);

112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
int get_num_ues(mid_t mod_id);

int get_ue_crnti (mid_t mod_id, mid_t ue_id);

int get_ue_bsr (mid_t mod_id, mid_t ue_id, lcid_t lcid);

int get_ue_phr (mid_t mod_id, mid_t ue_id);

int get_ue_wcqi (mid_t mod_id, mid_t ue_id);






/*******************
 * 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


/* Type of the callback executed when the timer expired */
typedef err_code_t (*enb_agent_timer_callback_t)(void*);

typedef enum {
  /* oneshot timer:  */
  ENB_AGENT_TIMER_TYPE_ONESHOT = 0x0,

  /* periodic timer  */
  ENB_AGENT_TIMER_TYPE_PERIODIC = 0x1,

  /* Inactive state: initial state for any timer. */
  ENB_AGENT_TIMER_TYPE_EVENT_DRIVEN = 0x2,
  
  /* Max number of states available */
  ENB_AGENT_TIMER_TYPE_MAX,
} eNB_agent_timer_type_t;

typedef enum {
  /* Inactive state: initial state for any timer. */
  ENB_AGENT_TIMER_STATE_INACTIVE = 0x0,

  /* Inactive state: initial state for any timer. */
  ENB_AGENT_TIMER_STATE_ACTIVE = 0x1,

  /* Inactive state: initial state for any timer. */
  ENB_AGENT_TIMER_STATE_STOPPED = 0x2,
  
  /* Max number of states available */
  ENB_AGENT_TIMER_STATE_MAX,
} eNB_agent_timer_state_t;

typedef struct enb_agent_timer_args_s{
  mid_t            mod_id;

  agent_action_t   cc_actions;
  uint32_t         cc_report_flags;

  agent_action_t   ue_actions;
  uint32_t         ue_report_flags;

} enb_agent_timer_args_t;



typedef struct enb_agent_timer_element_s{
  RB_ENTRY(enb_agent_timer_element_s) entry;

  agent_id_t             agent_id;
  instance_t       instance;
  
  eNB_agent_timer_type_t  type;
  eNB_agent_timer_state_t state;

  uint32_t interval_sec;
  uint32_t interval_usec;

  long timer_id;  /* Timer id returned by the timer API*/
  
  enb_agent_timer_callback_t cb;
197
  // void* timer_args;
198 199 200
  
} enb_agent_timer_element_t;

201 202 203
typedef struct enb_agent_timer_instance_s{
  RB_HEAD(enb_agent_map, enb_agent_timer_element_s) enb_agent_head;
}enb_agent_timer_instance_t;
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224

err_code_t enb_agent_init_timer(void);

err_code_t enb_agent_create_timer(uint32_t interval_sec,
				  uint32_t interval_usec,
				  agent_id_t     agent_id,
				  instance_t     instance,
				  uint32_t timer_type,
				  enb_agent_timer_callback_t cb,
				  void*    timer_args,
				  long *timer_id);

err_code_t enb_agent_destroy_timers(void);
err_code_t enb_agent_destroy_timer(long timer_id);

err_code_t enb_agent_stop_timer(long timer_id);

err_code_t enb_agent_restart_timer(long *timer_id);

struct enb_agent_timer_element_s * get_timer_entry(long timer_id);

225

226 227 228

err_code_t enb_agent_process_timeout(long timer_id, void* timer_args);

229
int enb_agent_compare_timer(struct enb_agent_timer_element_s *a, struct enb_agent_timer_element_s *b);
230 231 232 233 234

/* RB_PROTOTYPE is for .h files */
RB_PROTOTYPE(enb_agent_map, enb_agent_timer_element_s, entry, enb_agent_compare_timer);


235 236 237 238 239 240 241 242
#endif