proto.h 15 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
/*******************************************************************************
    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
24
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr
25 26 27 28 29 30 31

  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE

*******************************************************************************/
/*! \file proto.h
 * \brief RRC functions prototypes for eNB and UE
 * \author Navid Nikaein and Raymond Knopp
32
 * \date 2010 - 2014
33 34
 * \email navid.nikaein@eurecom.fr
 * \version 1.0
35 36 37 38
 
 */
/** \addtogroup _rrc
 *  @{
39 40
 */

41 42
#include "RRC/LITE/defs.h"

43 44 45
//main.c
int rrc_init_global_param(void);
int L3_xface_init(void);
knopp's avatar
knopp committed
46
void openair_rrc_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active,uint8_t HO_enabled);
47 48
#if defined(ENABLE_ITTI)
char
49
openair_rrc_eNB_configuration(
50 51 52 53
  const module_id_t enb_mod_idP,
  RrcConfigurationReq* configuration
);
#endif
54
char openair_rrc_eNB_init(
55 56
  const module_id_t module_idP);

57
char openair_rrc_ue_init(
58 59
  const module_id_t module_idP,
  const uint8_t CH_IDX);
60
void rrc_config_buffer(SRB_INFO *srb_info, uint8_t Lchan_type, uint8_t Role);
61 62 63
void
openair_rrc_on(
  const protocol_ctxt_t* const ctxt_pP);
64 65 66
void rrc_top_cleanup(void);

/** \brief Function to update timers every subframe.  For UE it updates T300,T304 and T310.
67 68 69
@param ctxt_pP  running context
@param enb_index
@param CC_id
70
*/
71 72
RRC_status_t
rrc_rx_tx(
73
  protocol_ctxt_t* const ctxt_pP,
74 75 76
  const uint8_t      enb_index,
  const int          CC_id
);
77 78 79 80

// UE RRC Procedures

/** \brief Decodes DL-CCCH message and invokes appropriate routine to handle the message
81
    \param ctxt_pP Running context
82 83
    \param Srb_info Pointer to SRB_INFO structure (SRB0)
    \param eNB_index Index of corresponding eNB/CH*/
84
int rrc_ue_decode_ccch( const protocol_ctxt_t* const ctxt_pP, const SRB_INFO* const Srb_info, const uint8_t eNB_index );
85 86

/** \brief Decodes a DL-DCCH message and invokes appropriate routine to handle the message
87
    \param ctxt_pP Running context
88 89
    \param Srb_id Index of Srb (1,2)
    \param buffer_pP Pointer to received SDU
90 91 92 93 94 95 96 97
    \param eNB_index Index of corresponding eNB/CH*/
void
rrc_ue_decode_dcch(
  const protocol_ctxt_t* const ctxt_pP,
  const rb_id_t                Srb_id,
  const uint8_t*         const Buffer,
  const uint8_t                eNB_indexP
);
98

99
/** \brief Generate/Encodes RRCConnnectionRequest message at UE
100
    \param ctxt_pP Running context
101
    \param eNB_index Index of corresponding eNB/CH*/
102 103 104 105 106
void
rrc_ue_generate_RRCConnectionRequest(
  const protocol_ctxt_t* const ctxt_pP,
  const uint8_t                eNB_index
);
107

108
/** \brief process the received rrcConnectionReconfiguration message at UE
109
    \param ctxt_pP Running context
110 111
    \param *rrcConnectionReconfiguration pointer to the sturcture
    \param eNB_index Index of corresponding eNB/CH*/
112 113 114 115 116 117
void
rrc_ue_process_rrcConnectionReconfiguration(
  const protocol_ctxt_t* const       ctxt_pP,
  RRCConnectionReconfiguration_t* rrcConnectionReconfiguration,
  uint8_t eNB_index
);
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

/** \brief Establish SRB1 based on configuration in SRB_ToAddMod structure.  Configures RLC/PDCP accordingly
    \param module_idP Instance ID of UE
    \param frame Frame index
    \param eNB_index Index of corresponding eNB/CH
    \param SRB_config Pointer to SRB_ToAddMod IE from configuration
    @returns 0 on success*/
int32_t  rrc_ue_establish_srb1(module_id_t module_idP,frame_t frameP,uint8_t eNB_index,struct SRB_ToAddMod *SRB_config);

/** \brief Establish SRB2 based on configuration in SRB_ToAddMod structure.  Configures RLC/PDCP accordingly
    \param module_idP Instance ID of UE
    \param frame Frame index
    \param eNB_index Index of corresponding eNB/CH
    \param SRB_config Pointer to SRB_ToAddMod IE from configuration
    @returns 0 on success*/
int32_t  rrc_ue_establish_srb2(module_id_t module_idP,frame_t frameP, uint8_t eNB_index,struct SRB_ToAddMod *SRB_config);

/** \brief Establish a DRB according to DRB_ToAddMod structure
    \param module_idP Instance ID of UE
    \param eNB_index Index of corresponding CH/eNB
    \param DRB_config Pointer to DRB_ToAddMod IE from configuration
    @returns 0 on success */
int32_t  rrc_ue_establish_drb(module_id_t module_idP,frame_t frameP,uint8_t eNB_index,struct DRB_ToAddMod *DRB_config);

/** \brief Process MobilityControlInfo Message to proceed with handover and configure PHY/MAC
143
    \param ctxt_pP Running context
144 145 146
    \param eNB_index Index of corresponding CH/eNB
    \param mobilityControlInfo Pointer to mobilityControlInfo
*/
147 148 149 150 151 152
void
rrc_ue_process_mobilityControlInfo(
  const protocol_ctxt_t* const       ctxt_pP,
  const uint8_t                      eNB_index,
  struct MobilityControlInfo* const mobilityControlInfo
);
153 154

/** \brief Process a measConfig Message and configure PHY/MAC
155
    \param  ctxt_pP    Running context
156 157
    \param eNB_index Index of corresponding CH/eNB
    \param  measConfig Pointer to MeasConfig  IE from configuration*/
158 159 160 161 162 163
void
rrc_ue_process_measConfig(
  const protocol_ctxt_t* const       ctxt_pP,
  const uint8_t                      eNB_index,
  MeasConfig_t* const               measConfig
);
164 165

/** \brief Process a RadioResourceConfigDedicated Message and configure PHY/MAC
166
    \param ctxt_pP Running context
167 168
    \param eNB_index Index of corresponding CH/eNB
    \param radioResourceConfigDedicated Pointer to RadioResourceConfigDedicated IE from configuration*/
169 170 171
void rrc_ue_process_radioResourceConfigDedicated(
  const protocol_ctxt_t* const ctxt_pP,
  uint8_t eNB_index,
172
  RadioResourceConfigDedicated_t *radioResourceConfigDedicated);
173 174 175 176 177 178 179 180 181

// eNB/CH RRC Procedures

/**\brief Function to get the next transaction identifier.
   \param module_idP Instance ID for CH/eNB
   \return a transaction identifier*/
uint8_t rrc_eNB_get_next_transaction_identifier(module_id_t module_idP);

/**\brief Entry routine to decode a UL-CCCH-Message.  Invokes PER decoder and parses message.
182
   \param ctxt_pP Running context
183
   \param Srb_info Pointer to SRB0 information structure (buffer, etc.)*/
184 185 186
int
rrc_eNB_decode_ccch(
  protocol_ctxt_t* const ctxt_pP,
187 188
  const SRB_INFO*        const Srb_info,
  const int              CC_id
189
);
190 191

/**\brief Entry routine to decode a UL-DCCH-Message.  Invokes PER decoder and parses message.
192
   \param ctxt_pP Context
193 194
   \param Rx_sdu Pointer Received Message
   \param sdu_size Size of incoming SDU*/
195 196 197 198 199 200 201
int
rrc_eNB_decode_dcch(
  const protocol_ctxt_t* const ctxt_pP,
  const rb_id_t                Srb_id,
  const uint8_t*    const      Rx_sdu,
  const sdu_size_t             sdu_sizeP
);
202 203

/**\brief Generate the RRCConnectionSetup based on information coming from RRM
204 205 206 207 208
   \param ctxt_pP       Running context
   \param ue_context_pP UE context*/
void
rrc_eNB_generate_RRCConnectionSetup(
  const protocol_ctxt_t* const ctxt_pP,
209 210
  rrc_eNB_ue_context_t* const ue_context_pP,
  const int                    CC_id
211
);
212

213 214 215 216 217 218 219 220 221 222 223
/**\brief Generate RRCConnectionReestablishmentReject
   \param ctxt_pP       Running context
   \param ue_context_pP UE context
   \param CC_id         Component Carrier ID*/
void
rrc_eNB_generate_RRCConnectionReestablishmentReject(
  const protocol_ctxt_t* const ctxt_pP,
  rrc_eNB_ue_context_t* const ue_context_pP,
  const int                    CC_id
);

224
/**\brief Process the RRCConnectionSetupComplete based on information coming from UE
225 226
   \param ctxt_pP       Running context
   \param ue_context_pP RRC UE context
227
   \param rrcConnectionSetupComplete Pointer to RRCConnectionSetupComplete message*/
228 229 230
void
rrc_eNB_process_RRCConnectionSetupComplete(
  const protocol_ctxt_t* const ctxt_pP,
231
  rrc_eNB_ue_context_t*        ue_context_pP,
232 233
  RRCConnectionSetupComplete_r8_IEs_t* rrcConnectionSetupComplete
);
234 235

/**\brief Process the RRCConnectionReconfigurationComplete based on information coming from UE
236 237
   \param ctxt_pP       Running context
   \param ue_context_pP RRC UE context
238 239 240
   \param rrcConnectionReconfigurationComplete Pointer to RRCConnectionReconfigurationComplete message
   \param xid         the transaction id for the rrcconnectionreconfiguration procedure
*/
241 242 243
void
rrc_eNB_process_RRCConnectionReconfigurationComplete(
  const protocol_ctxt_t* const ctxt_pP,
244 245
  rrc_eNB_ue_context_t*        ue_context_pP,
  const uint8_t xid
246
);
247

248
/**\brief Generate the RRCConnectionRelease
249 250 251 252 253 254 255 256 257 258 259 260 261 262
   \param ctxt_pP Running context
   \param ue_context_pP UE context of UE receiving the message*/
void
rrc_eNB_generate_RRCConnectionRelease(
  const protocol_ctxt_t* const ctxt_pP,
  rrc_eNB_ue_context_t*          const ue_context_pP
);

void
rrc_eNB_generate_defaultRRCConnectionReconfiguration(
  const protocol_ctxt_t* const ctxt_pP,
  rrc_eNB_ue_context_t*          const ue_context_pP,
  const uint8_t                ho_state
);
263

264 265 266 267 268 269 270 271 272 273 274
void
rrc_eNB_generate_dedeicatedRRCConnectionReconfiguration(
  const protocol_ctxt_t* const ctxt_pP,
  rrc_eNB_ue_context_t*          const ue_context_pP,
  const uint8_t                ho_state
);

void 
rrc_eNB_reconfigure_DRBs (const protocol_ctxt_t* const ctxt_pP,
			  rrc_eNB_ue_context_t*  ue_context_pP);

275 276 277 278 279 280 281 282 283 284 285 286 287 288
#if defined(ENABLE_ITTI)
/**\brief RRC eNB task.
   \param void *args_p Pointer on arguments to start the task. */
void *rrc_enb_task(void *args_p);

/**\brief RRC UE task.
   \param void *args_p Pointer on arguments to start the task. */
void *rrc_ue_task(void *args_p);
#endif

/**\brief Generate/decode the handover RRCConnectionReconfiguration at eNB
   \param module_idP Instance ID for eNB/CH
   \param frame Frame index
   \param ue_module_idP Index of UE transmitting the messages*/
289 290 291 292 293 294 295
void
rrc_eNB_generate_RRCConnectionReconfiguration_handover(
  const protocol_ctxt_t* const ctxt_pP,
  rrc_eNB_ue_context_t*           const ue_context_pP,
  uint8_t*                const nas_pdu,
  const uint32_t                nas_length
);
296 297

//L2_interface.c
298
int8_t
299
mac_rrc_data_req(
300
  const module_id_t Mod_idP,
301
  const int         CC_id,
302 303 304 305 306 307 308 309 310 311
  const frame_t     frameP,
  const rb_id_t     Srb_id,
  const uint8_t     Nb_tb,
  uint8_t*    const buffer_pP,
  const eNB_flag_t  enb_flagP,
  const uint8_t     eNB_index,
  const uint8_t     mbsfn_sync_area
);

int8_t
312
mac_rrc_data_ind(
313
  const module_id_t     module_idP,
314
  const int         CC_id,
315
  const frame_t         frameP,
316
  const sub_frame_t     sub_frameP,
317 318 319 320 321 322 323 324
  const rnti_t          rntiP,
  const rb_id_t         srb_idP,
  const uint8_t*        sduP,
  const sdu_size_t      sdu_lenP,
  const eNB_flag_t      eNB_flagP,
  const mac_enb_index_t eNB_indexP,
  const uint8_t         mbsfn_sync_areaP
);
325 326 327

void mac_sync_ind( module_id_t Mod_instP, uint8_t status);

328 329 330 331 332 333
void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, 
			    const int CC_id, 
			    const frame_t frameP,
			    const sub_frame_t subframeP,
			    const rnti_t rnti);

334 335 336 337 338 339
void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, 
			    const int CC_id, 
			    const frame_t frameP,
			    const sub_frame_t subframeP,
			    const rnti_t rnti);

340
uint8_t
341
rrc_data_req(
342 343 344 345 346 347 348 349 350 351
  const protocol_ctxt_t*   const ctxt_pP,
  const rb_id_t                  rb_idP,
  const mui_t                    muiP,
  const confirm_t                confirmP,
  const sdu_size_t               sdu_size,
  uint8_t*                 const buffer_pP,
  const pdcp_transmission_mode_t modeP
);

void
352
rrc_data_ind(
353 354 355 356 357
  const protocol_ctxt_t* const ctxt_pP,
  const rb_id_t                Srb_id,
  const sdu_size_t             sdu_sizeP,
  const uint8_t*   const       buffer_pP
);
358

359
void rrc_in_sync_ind(module_id_t module_idP, frame_t frameP, uint16_t eNB_index);
360

361
void rrc_out_of_sync_ind(module_id_t module_idP, frame_t frameP, unsigned short eNB_index);
362

363
int decode_MCCH_Message( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t* const Sdu, const uint8_t Sdu_len, const uint8_t mbsfn_sync_area );
364

365
int decode_BCCH_DLSCH_Message(
366 367 368 369 370
  const protocol_ctxt_t* const ctxt_pP,
  const uint8_t                eNB_index,
  uint8_t*               const Sdu,
  const uint8_t                Sdu_len,
  const uint8_t                rsrq,
371
  const uint8_t                rsrp );
372

373 374 375 376 377 378
int decode_PCCH_DLSCH_Message(
  const protocol_ctxt_t* const ctxt_pP,
  const uint8_t                eNB_index,
  uint8_t*               const Sdu,
  const uint8_t                Sdu_len);

379 380 381 382 383 384 385 386
void
ue_meas_filtering(
  const protocol_ctxt_t* const ctxt_pP,
  const uint8_t                eNB_index
);

void
ue_measurement_report_triggering(
387
  protocol_ctxt_t*        const ctxt_pP,
388 389 390 391
  const uint8_t                 eNB_index
);

int
392
mac_eNB_get_rrc_status(
393 394 395 396 397
  const module_id_t Mod_idP,
  const rnti_t      rntiP
);

int
398
mac_UE_get_rrc_status(
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
  const module_id_t Mod_idP,
  const uint8_t     indexP
);

void
rrc_eNB_generate_UECapabilityEnquiry(
  const protocol_ctxt_t* const ctxt_pP,
  rrc_eNB_ue_context_t*          const ue_context_pP
);

void
rrc_eNB_generate_SecurityModeCommand(
  const protocol_ctxt_t* const ctxt_pP,
  rrc_eNB_ue_context_t*          const ue_context_pP
);

void
rrc_eNB_process_MeasurementReport(
  const protocol_ctxt_t* const ctxt_pP,
  rrc_eNB_ue_context_t*          const ue_context_pP,
  const MeasResults_t*   const measResults2
);

void
rrc_eNB_generate_HandoverPreparationInformation(
  const protocol_ctxt_t* const ctxt_pP,
  rrc_eNB_ue_context_t*          const ue_context_pP,
  PhysCellId_t targetPhyId
);

void
check_handovers(
  protocol_ctxt_t* const ctxt_pP
);

//void rrc_ue_process_ueCapabilityEnquiry(uint8_t module_idP,uint32_t frame,UECapabilityEnquiry_t *UECapabilityEnquiry,uint8_t eNB_index);
/*void
rrc_ue_process_securityModeCommand(
                const protocol_ctxt_t* const ctxt_pP,
                SecurityModeCommand_t *const securityModeCommand,
                const uint8_t                eNB_index
                );
*/
442

443 444 445 446 447 448 449 450 451
#if !defined(ENABLE_USE_MME)
void rrc_eNB_emulation_notify_ue_module_id(
  const module_id_t ue_module_idP,
  const rnti_t      rntiP,
  const uint8_t     cell_identity_byte0P,
  const uint8_t     cell_identity_byte1P,
  const uint8_t     cell_identity_byte2P,
  const uint8_t     cell_identity_byte3P);
#endif
452 453


454 455 456 457 458
void
rrc_eNB_free_mem_UE_context(
  const protocol_ctxt_t*               const ctxt_pP,
  struct rrc_eNB_ue_context_s*         const ue_context_pP
);
459 460


461 462
void
rrc_eNB_free_UE(
463 464
		const module_id_t enb_mod_idP,
		const struct rrc_eNB_ue_context_s*         const ue_context_pP
465
);
466 467 468 469 470

long binary_search_int(int elements[], long numElem, int value);

long binary_search_float(float elements[], long numElem, float value);

471
/** @}*/