proto.h 17.5 KB
Newer Older
1
2
3
4
5
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
Cedric Roux's avatar
Cedric Roux committed
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */

22
23
24
/*! \file proto.h
 * \brief RRC functions prototypes for eNB and UE
 * \author Navid Nikaein and Raymond Knopp
25
 * \date 2010 - 2014
26
27
 * \email navid.nikaein@eurecom.fr
 * \version 1.0
28
29
30
31
 
 */
/** \addtogroup _rrc
 *  @{
32
33
 */

34
35
#include "RRC/LITE/defs.h"

36
37
38
//main.c
int rrc_init_global_param(void);
int L3_xface_init(void);
knopp's avatar
   
knopp committed
39
void openair_rrc_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active,uint8_t HO_enabled);
40
41
#if defined(ENABLE_ITTI)
char
42
openair_rrc_eNB_configuration(
43
44
45
46
  const module_id_t enb_mod_idP,
  RrcConfigurationReq* configuration
);
#endif
47
char openair_rrc_eNB_init(
48
49
  const module_id_t module_idP);

50
char openair_rrc_ue_init(
51
52
  const module_id_t module_idP,
  const uint8_t CH_IDX);
53
void rrc_config_buffer(SRB_INFO *srb_info, uint8_t Lchan_type, uint8_t Role);
54
55
56
void
openair_rrc_on(
  const protocol_ctxt_t* const ctxt_pP);
57
58
59
void rrc_top_cleanup(void);

/** \brief Function to update timers every subframe.  For UE it updates T300,T304 and T310.
60
61
62
@param ctxt_pP  running context
@param enb_index
@param CC_id
63
*/
64
65
RRC_status_t
rrc_rx_tx(
66
  protocol_ctxt_t* const ctxt_pP,
67
68
69
  const uint8_t      enb_index,
  const int          CC_id
);
70
71
72
73

// UE RRC Procedures

/** \brief Decodes DL-CCCH message and invokes appropriate routine to handle the message
74
    \param ctxt_pP Running context
75
76
    \param Srb_info Pointer to SRB_INFO structure (SRB0)
    \param eNB_index Index of corresponding eNB/CH*/
77
int rrc_ue_decode_ccch( const protocol_ctxt_t* const ctxt_pP, const SRB_INFO* const Srb_info, const uint8_t eNB_index );
78
79

/** \brief Decodes a DL-DCCH message and invokes appropriate routine to handle the message
80
    \param ctxt_pP Running context
81
82
    \param Srb_id Index of Srb (1,2)
    \param buffer_pP Pointer to received SDU
83
84
85
86
87
88
89
90
    \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
);
91

92
/** \brief Generate/Encodes RRCConnnectionRequest message at UE
93
    \param ctxt_pP Running context
94
    \param eNB_index Index of corresponding eNB/CH*/
95
96
97
98
99
void
rrc_ue_generate_RRCConnectionRequest(
  const protocol_ctxt_t* const ctxt_pP,
  const uint8_t                eNB_index
);
100

101
/** \brief process the received rrcConnectionReconfiguration message at UE
102
    \param ctxt_pP Running context
103
104
    \param *rrcConnectionReconfiguration pointer to the sturcture
    \param eNB_index Index of corresponding eNB/CH*/
105
106
107
108
109
110
void
rrc_ue_process_rrcConnectionReconfiguration(
  const protocol_ctxt_t* const       ctxt_pP,
  RRCConnectionReconfiguration_t* rrcConnectionReconfiguration,
  uint8_t eNB_index
);
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

/** \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
136
    \param ctxt_pP Running context
137
138
139
    \param eNB_index Index of corresponding CH/eNB
    \param mobilityControlInfo Pointer to mobilityControlInfo
*/
140
141
142
143
144
145
void
rrc_ue_process_mobilityControlInfo(
  const protocol_ctxt_t* const       ctxt_pP,
  const uint8_t                      eNB_index,
  struct MobilityControlInfo* const mobilityControlInfo
);
146
147

/** \brief Process a measConfig Message and configure PHY/MAC
148
    \param  ctxt_pP    Running context
149
150
    \param eNB_index Index of corresponding CH/eNB
    \param  measConfig Pointer to MeasConfig  IE from configuration*/
151
152
153
154
155
156
void
rrc_ue_process_measConfig(
  const protocol_ctxt_t* const       ctxt_pP,
  const uint8_t                      eNB_index,
  MeasConfig_t* const               measConfig
);
157
158

/** \brief Process a RadioResourceConfigDedicated Message and configure PHY/MAC
159
    \param ctxt_pP Running context
160
161
    \param eNB_index Index of corresponding CH/eNB
    \param radioResourceConfigDedicated Pointer to RadioResourceConfigDedicated IE from configuration*/
162
163
164
void rrc_ue_process_radioResourceConfigDedicated(
  const protocol_ctxt_t* const ctxt_pP,
  uint8_t eNB_index,
165
  RadioResourceConfigDedicated_t *radioResourceConfigDedicated);
166

167
168
169
170
171
172
173
174

/** \brief Process a RadioResourceConfig and configure PHY/MAC for SL communication/discovery
    \param Mod_idP
    \param eNB_index Index of corresponding CH/eNB
    \param sib18 Pointer to SIB18 from SI message
    \param sib19 Pointer to SIB19 from SI message
    \param sl_CommConfig Pointer to SL_CommConfig RRCConnectionConfiguration
    \param sl_DiscConfig Pointer to SL_DiscConfig RRCConnectionConfiguration */
Tien-Thinh Nguyen's avatar
Tien-Thinh Nguyen committed
175
void rrc_ue_process_sidelink_radioResourceConfig(
176
177
178
179
180
181
182
  module_id_t Mod_idP,
  uint8_t eNB_index,
  SystemInformationBlockType18_r12_t     *sib18,
  SystemInformationBlockType19_r12_t     *sib19,
  SL_CommConfig_r12_t* sl_CommConfig,
  SL_DiscConfig_r12_t* sl_DiscConfig);

183
184
185
186
187
188
/** \brief Init control socket to listen to incoming packets from ProSe App
 *
 */
void
rrc_control_socket_init();

189

190
191
192
193
194
195
196
197
// 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.
198
   \param ctxt_pP Running context
199
   \param Srb_info Pointer to SRB0 information structure (buffer, etc.)*/
200
201
202
int
rrc_eNB_decode_ccch(
  protocol_ctxt_t* const ctxt_pP,
203
204
  const SRB_INFO*        const Srb_info,
  const int              CC_id
205
);
206
207

/**\brief Entry routine to decode a UL-DCCH-Message.  Invokes PER decoder and parses message.
208
   \param ctxt_pP Context
209
210
   \param Rx_sdu Pointer Received Message
   \param sdu_size Size of incoming SDU*/
211
212
213
214
215
216
217
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
);
218
219

/**\brief Generate the RRCConnectionSetup based on information coming from RRM
220
221
222
223
224
   \param ctxt_pP       Running context
   \param ue_context_pP UE context*/
void
rrc_eNB_generate_RRCConnectionSetup(
  const protocol_ctxt_t* const ctxt_pP,
225
226
  rrc_eNB_ue_context_t* const ue_context_pP,
  const int                    CC_id
227
);
228

229
230
231
232
233
234
235
236
237
238
239
/**\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
);

240
/**\brief Process the RRCConnectionSetupComplete based on information coming from UE
241
242
   \param ctxt_pP       Running context
   \param ue_context_pP RRC UE context
243
   \param rrcConnectionSetupComplete Pointer to RRCConnectionSetupComplete message*/
244
245
246
void
rrc_eNB_process_RRCConnectionSetupComplete(
  const protocol_ctxt_t* const ctxt_pP,
247
  rrc_eNB_ue_context_t*        ue_context_pP,
248
249
  RRCConnectionSetupComplete_r8_IEs_t* rrcConnectionSetupComplete
);
250
251

/**\brief Process the RRCConnectionReconfigurationComplete based on information coming from UE
252
253
   \param ctxt_pP       Running context
   \param ue_context_pP RRC UE context
254
255
256
   \param rrcConnectionReconfigurationComplete Pointer to RRCConnectionReconfigurationComplete message
   \param xid         the transaction id for the rrcconnectionreconfiguration procedure
*/
257
258
259
void
rrc_eNB_process_RRCConnectionReconfigurationComplete(
  const protocol_ctxt_t* const ctxt_pP,
260
261
  rrc_eNB_ue_context_t*        ue_context_pP,
  const uint8_t xid
262
);
263

264
/**\brief Generate the RRCConnectionRelease
265
266
267
268
269
270
271
272
273
274
275
276
277
278
   \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
);
279

280
281
282
283
284
285
286
287
288
289
290
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);

291
292
293
294
295
296
297
298
299
300
301
302
303
304
#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*/
305
306
307
308
309
310
311
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
);
312

313
/**\brief Generate/decode the RRCConnectionReconfiguration for Sidelink at eNB
314
315
316
317
   \param ctxt_pP       Running context
   \param ue_context_pP RRC UE context
   \param destinationInfoList List of the destinations
   \param n_discoveryMessages Number of discovery messages*/
318
319
320
int
rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(
      const protocol_ctxt_t* const ctxt_pP,
321
      rrc_eNB_ue_context_t*           const ue_context_pP,
322
      SL_DestinationInfoList_r12_t  *destinationInfoList,
323
      int n_discoveryMessages
324
325
);

326
/** \brief process the received SidelinkUEInformation message at eNB
327
    \param ctxt_pP Running context
328
329
    \param sidelinkUEInformation sidelinkUEInformation message from UE*/
uint8_t
330
331
332
rrc_eNB_process_SidelinkUEInformation(
      const protocol_ctxt_t* const ctxt_pP,
      rrc_eNB_ue_context_t*         ue_context_pP,
333
      SidelinkUEInformation_r12_t*  sidelinkUEInformation
334
335
);

336
/** \brief Get a Resource Pool to transmit SL communication
337
338
339
340
341
342
343
344
345
    \param ctxt_pP Running context
    \param ue_context_pP UE context
    \param destinationInfoList Pointer to the list of SL destinations*/
SL_CommConfig_r12_t rrc_eNB_get_sidelink_commTXPool(
      const protocol_ctxt_t* const ctxt_pP,
      rrc_eNB_ue_context_t* const ue_context_pP,
      SL_DestinationInfoList_r12_t  *destinationInfoList
);

346
347
348
349
350
351
352
353
354
355
356
357
/** \brief Get a Resource Pool for Discovery
    \param ctxt_pP Running context
    \param ue_context_pP UE context
    \param n_discoveryMessages Number of discovery messages*/
SL_DiscConfig_r12_t rrc_eNB_get_sidelink_discTXPool(
      const protocol_ctxt_t* const ctxt_pP,
      rrc_eNB_ue_context_t* const ue_context_pP,
      int n_discoveryMessages
);



358
//L2_interface.c
359
int8_t
360
mac_rrc_data_req(
361
  const module_id_t Mod_idP,
362
  const int         CC_id,
363
364
365
366
367
368
369
370
371
372
  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
373
mac_rrc_data_ind(
374
  const module_id_t     module_idP,
375
  const int         CC_id,
376
  const frame_t         frameP,
gauthier's avatar
gauthier committed
377
  const sub_frame_t     sub_frameP,
378
379
380
381
382
383
384
385
  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
);
386
387
388

void mac_sync_ind( module_id_t Mod_instP, uint8_t status);

389
390
391
392
393
394
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);

Florian Kaltenberger's avatar
Florian Kaltenberger committed
395
396
397
398
399
400
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);

401
uint8_t
402
rrc_data_req(
403
404
405
406
407
408
409
410
411
412
  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
413
rrc_data_ind(
414
415
416
417
418
  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
);
419

420
void rrc_in_sync_ind(module_id_t module_idP, frame_t frameP, uint16_t eNB_index);
421

422
void rrc_out_of_sync_ind(module_id_t module_idP, frame_t frameP, unsigned short eNB_index);
423

424
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 );
425

426
int decode_BCCH_DLSCH_Message(
427
428
429
430
431
  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,
432
  const uint8_t                rsrp );
433

434
435
436
437
438
439
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);

440
441
442
443
444
445
446
447
void
ue_meas_filtering(
  const protocol_ctxt_t* const ctxt_pP,
  const uint8_t                eNB_index
);

void
ue_measurement_report_triggering(
448
  protocol_ctxt_t*        const ctxt_pP,
449
450
451
452
  const uint8_t                 eNB_index
);

int
453
mac_eNB_get_rrc_status(
454
455
456
457
458
  const module_id_t Mod_idP,
  const rnti_t      rntiP
);

int
459
mac_UE_get_rrc_status(
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
  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
                );
*/
503

504
505
506
507
508
509
510
511
512
#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
513
514


515
516
517
518
519
void
rrc_eNB_free_mem_UE_context(
  const protocol_ctxt_t*               const ctxt_pP,
  struct rrc_eNB_ue_context_s*         const ue_context_pP
);
520
521


522
523
void
rrc_eNB_free_UE(
524
525
		const module_id_t enb_mod_idP,
		const struct rrc_eNB_ue_context_s*         const ue_context_pP
526
);
527
528
529
530
531

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

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

532
void openair_rrc_top_init_eNB(int eMBMS_active,uint8_t HO_active);
Cedric Roux's avatar
Cedric Roux committed
533
534
535
536
537
538
539
540

void openair_rrc_top_init_ue(
                        int eMBMS_active,
                        char* uecap_xer,
                        uint8_t cba_group_active,
                        uint8_t HO_active
);

541
/** @}*/