proto_NB_IoT.h 18.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/* 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
 * the OAI Public License, Version 1.0  (the "License"); you may not use this file
 * 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
 */

21
/*! \file proto_NB_IoT.h
22 23 24 25 26 27 28 29 30 31 32
 * \brief RRC functions prototypes for eNB and UE for NB-IoT
 * \author Navid Nikaein, Raymond Knopp and Michele Paffetti
 * \date 2010 - 2014
 * \email navid.nikaein@eurecom.fr, michele.paffetti@studio.unibo.it
 * \version 1.0

 */
/** \addtogroup _rrc
 *  @{
 */

33
#include "RRC/LITE/defs_NB_IoT.h"
34 35
#include "pdcp.h"
#include "rlc.h"
36
#include "extern_NB_IoT.h"
37
#include "LAYER2/MAC/defs_NB_IoT.h"
38 39
/*NOTE: no static function should be declared in this header file (e.g. init_SI_NB)*/

40 41
uint8_t *get_NB_IoT_SIB1(void);

42 43
uint8_t *get_NB_IoT_MIB(void);

44 45
long *get_NB_IoT_SIB1_eutracontrolregionsize(void);

46 47
void init_testing_NB_IoT(uint8_t Mod_id, int CC_id, rrc_eNB_carrier_data_NB_IoT_t *carrier, RrcConfigurationReq *configuration, uint32_t frame, uint32_t hyper_frame);

48 49 50 51
/*------------------------common_nb_iot.c----------------------------------------*/

/** \brief configure  BCCH & CCCH Logical Channels and associated rrc_buffers, configure associated SRBs
 */
52
void openair_rrc_on_NB_IoT(const protocol_ctxt_t* const ctxt_pP);
53

54
void rrc_config_buffer_NB_IoT(SRB_INFO_NB_IoT *srb_info, uint8_t Lchan_type, uint8_t Role);
55

56
int L3_xface_init_NB_IoT(void);
57

58
void openair_rrc_top_init_eNB_NB_IoT(void);
59 60 61 62 63 64 65 66 67 68

//void rrc_top_cleanup(void); -->seems not to be used

//rrc_t310_expiration-->seems not to be used

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

//long binary_search_int(int elements[], long numElem, int value);--> seems not to be used
//long binary_search_float(float elements[], long numElem, float value);--> used only at UE side


75

76 77
//---------------------------------------

78

79 80
//defined in L2_interface
//called by rx_sdu only in case of CCCH message (e.g RRCConnectionRequest-NB)
81
int8_t mac_rrc_data_ind_eNB_NB_IoT(
82 83 84 85 86 87 88 89 90 91 92
  const module_id_t     module_idP,
  const int             CC_id,
  const frame_t         frameP,
  const sub_frame_t     sub_frameP,
  const rnti_t          rntiP,
  const rb_id_t         srb_idP,//could be skipped since always go through the CCCH channel
  const uint8_t*        sduP,
  const sdu_size_t      sdu_lenP
);
//-------------------------------------------

93
//defined in L2_interface
94
void dump_ue_list_NB_IoT(UE_list_NB_IoT_t *listP, int ul_flag);
95 96 97
//-------------------------------------------


98
//defined in L2_interface
99
void mac_eNB_rrc_ul_failure_NB_IoT(
100 101 102 103 104 105 106 107
		const module_id_t mod_idP,
	    const int CC_idP,
	    const frame_t frameP,
	    const sub_frame_t subframeP,
	    const rnti_t rntiP);
//------------------------------------------

//defined in eNB_scheduler_primitives.c
108
int rrc_mac_remove_ue_NB_IoT(
109 110 111 112
		module_id_t mod_idP,
		rnti_t rntiP);
//------------------------------------------
//defined in L2_interface
113
void mac_eNB_rrc_ul_in_sync_NB_IoT(
114 115 116 117 118 119 120
				const module_id_t mod_idP,
			    const int CC_idP,
			    const frame_t frameP,
			    const sub_frame_t subframeP,
			    const rnti_t rntiP);
//------------------------------------------
//defined in L2_interface
121
int mac_eNB_get_rrc_status_NB_IoT(
122 123 124 125 126
  const module_id_t Mod_idP,
  const rnti_t      rntiP
);
//---------------------------

127
//----------------------------------------
128
int pdcp_apply_security_NB_IoT(
129 130 131 132 133 134 135 136 137 138 139 140 141
  const protocol_ctxt_t* const ctxt_pP,
  pdcp_t        *const pdcp_pP,
  const srb_flag_t     srb_flagP,
  const rb_id_t        rb_id, //rb_idP % maxDRB_NB_r13
  const uint8_t        pdcp_header_len,
  const uint16_t       current_sn,
  uint8_t       * const pdcp_pdu_buffer,
  const uint16_t      sdu_buffer_size
);
//-------------------------------------------


//XXX for the moment we not configure PDCP for SRB1bis (but used as it is SRB1)
142
//defined in pdcp.c
143
boolean_t rrc_pdcp_config_asn1_req_NB_IoT (
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
  const protocol_ctxt_t* const  ctxt_pP,
  SRB_ToAddModList_NB_r13_t  *const srb2add_list_pP,
  DRB_ToAddModList_NB_r13_t  *const drb2add_list_pP,
  DRB_ToReleaseList_NB_r13_t *const drb2release_list_pP,
  const uint8_t                   security_modeP,
  uint8_t                  *const kRRCenc_pP,
  uint8_t                  *const kRRCint_pP,
  uint8_t                  *const kUPenc_pP,
  rb_id_t                 *const defaultDRB,
  long						LCID
);
//--------------------------------------------------

//defined in pdcp.c --> should be called only by a SRB1 (is internal to PDCP so is not an interface)
//-----------------------------------------------------------------------------
159
boolean_t pdcp_config_req_asn1_NB_IoT (
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
  const protocol_ctxt_t* const  ctxt_pP,
  pdcp_t         * const        pdcp_pP,
  const srb_flag_t              srb_flagP,
  const rlc_mode_t              rlc_modeP, //rlc_type
  const config_action_t         actionP,
  const uint16_t                lc_idP, // 1 = SRB1 // 3 = SRB1bis // >= 4 for DRBs
  const rb_id_t                 rb_idP,
  const uint8_t                 rb_snP, //5 if srb_sn // 7 is drb_sn // 0 if drb_sn to be removed
  const uint8_t                 rb_reportP, //not for SRBand not for NB-IOT
  const uint16_t                header_compression_profileP, //not for SRB only DRB
  const uint8_t                 security_modeP,
  uint8_t         *const        kRRCenc_pP,
  uint8_t         *const        kRRCint_pP,
  uint8_t         *const        kUPenc_pP);
//-----------------------------------------------------------------------------

//defined in L2_interface/pdcp.c
//FIXME SRB1bis should bypass the pdcp
//Distinction between different SRBs will be done by means of rd_id
179
uint8_t rrc_data_req_NB_IoT(
180 181 182 183 184 185 186 187 188 189
  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_sizeP,
  uint8_t*                 const buffer_pP,
  const pdcp_transmission_mode_t modeP //when go through SRB1bis should be set as Transparent mode
);
//-------------------------------------------------------------
//we distinguish the SRBs based on the logical channel id and the transmission mode
190
boolean_t pdcp_data_req_NB_IoT(
191 192 193 194 195 196 197 198 199 200 201 202 203
  protocol_ctxt_t*  ctxt_pP,
  const srb_flag_t     srb_flagP, //SRB_FLAG_YES if called by RRC
  const rb_id_t        rb_idP,
  const mui_t          muiP,
  const confirm_t      confirmP,
  const sdu_size_t     sdu_buffer_sizeP, //the size of message that i should transmit
  unsigned char *const sdu_buffer_pP,
  const pdcp_transmission_mode_t modeP
);

//----------------------------------------------------------------

//defined in L2_interface
204
void rrc_data_ind_NB_IoT(
205 206 207 208 209 210 211 212 213
  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,
  const srb1bis_flag_t srb1bis_flag
);
//------------------------------------------------------------------------------

//defined in rlc_rrc.c
214
rlc_op_status_t rrc_rlc_config_asn1_req_NB_IoT (
215 216 217 218 219 220 221 222 223
	const protocol_ctxt_t   * const ctxt_pP,
    const SRB_ToAddModList_NB_r13_t   * const srb2add_listP,
    const DRB_ToAddModList_NB_r13_t   * const drb2add_listP,
    const DRB_ToReleaseList_NB_r13_t  * const drb2release_listP,
	srb1bis_flag_t							srb1bis_flag
    );
//-------------------------------------------------------------------------

// defined in rlc_am.c
224
void config_req_rlc_am_asn1_NB_IoT (
225 226 227 228 229 230 231 232 233
  const protocol_ctxt_t* const         ctxt_pP,
  const srb_flag_t                     srb_flagP,
  const struct RLC_Config_NB_r13__am  * const config_am_pP, //extracted from the srb_toAddMod
  const rb_id_t                        rb_idP,
  const logical_chan_id_t              chan_idP);
//------------------------------------------------------------

//defined in rlc_am_init.c
//------------------------------------------------------------
234
void rlc_am_configure_NB_IoT(
235 236 237 238
  const protocol_ctxt_t* const  ctxt_pP,
  rlc_am_entity_t *const        rlc_pP,
  const uint16_t                max_retx_thresholdP,
  const uint16_t                t_poll_retransmitP,
239
  uint32_t                      *enableStatusReportSN_Gap
240 241 242 243 244
  );
//--------------------------------------------------------------

//defined in rlc_rrc.c
//-------------------------------------------------------------
245
rlc_union_t* rrc_rlc_add_rlc_NB_IoT (
246 247 248 249 250 251 252 253 254
  const protocol_ctxt_t* const ctxt_pP,
  const srb_flag_t        srb_flagP,
  const rb_id_t           rb_idP,
  const logical_chan_id_t chan_idP,
  const rlc_mode_t        rlc_modeP);
//--------------------------------------------------------------

//defined in rlc_rrc.c
//--------------------------------------------------------------
255
rlc_op_status_t rrc_rlc_remove_rlc_NB_IoT (
256 257 258 259 260 261 262
  const protocol_ctxt_t* const ctxt_pP,
  const srb_flag_t  srb_flagP,
  const rb_id_t     rb_idP);
//----------------------------------------------

//defined in rlc_rrc.c //used only for process_RRCConnectionReconfigurationComplete --> CONFIG_ACTION_REMOVE
//used also for rrc_t310_expiration --> I don't know if it is used (probably not)
263
rlc_op_status_t rrc_rlc_config_req_NB_IoT (
264 265 266 267
  const protocol_ctxt_t* const ctxt_pP,
  const srb_flag_t      srb_flagP,
  const config_action_t actionP,
  const rb_id_t         rb_idP,
268
   rlc_info_t      rlc_infoP);
269 270 271 272 273
//-----------------------------------------------------


//defined in rlc_am.c
//------------------------------------------------------
274
void config_req_rlc_am_NB_IoT (
275
  const protocol_ctxt_t        * const ctxt_pP,
276
  const srb_flag_t             srb_flagP,
277
  rlc_am_info_NB_IoT_t         *const config_am_pP, //XXX: MP: rlc_am_init.c --> this structure has been modified for NB-IoT
278 279 280 281 282 283 284
  const rb_id_t                rb_idP,
  const logical_chan_id_t      chan_idP
);
//--------------------------------------------------------

//defined in rlc_tm_init.c (nothing to be changed)
//-----------------------------------------------------------------------------
285
void config_req_rlc_tm_NB_IoT (
286 287 288 289 290 291 292 293
  const protocol_ctxt_t* const  ctxt_pP,
  const srb_flag_t  srb_flagP,
  const rlc_tm_info_t * const config_tmP,
  const rb_id_t rb_idP,
  const logical_chan_id_t chan_idP
);
//------------------------------------------------------
//defined in rlc_rrc.c
294
rlc_op_status_t rrc_rlc_remove_ue_NB_IoT (
295 296 297 298 299
  const protocol_ctxt_t* const ctxt_pP);
//----------------------------------------------------

//defined in rlc.c
//--------------------------------------------
300
void rlc_data_ind_NB_IoT  (
301 302 303 304 305 306 307 308 309 310
  const protocol_ctxt_t* const ctxt_pP,
  const srb_flag_t  srb_flagP,
  const srb1bis_flag_t srb1bis_flag,
  const rb_id_t     rb_idP,
  const sdu_size_t  sdu_sizeP,
  mem_block_t      *sdu_pP);
//---------------------------------------------

//defined in rlc.c
//-----------------------------------------------------------------------------
311 312 313 314 315 316 317
rlc_op_status_t rlc_data_req_NB_IoT  (const protocol_ctxt_t* const ctxt_pP,
                                      const srb_flag_t   srb_flagP,
                                      const rb_id_t      rb_idP,
                                      const mui_t        muiP,
                                      confirm_t    confirmP,
                                      sdu_size_t   sdu_sizeP,
                                      mem_block_t *sdu_pP);
318 319
//-----------------------------------------------------------------------------

320 321 322

//defined in rlc_rrc.c --> NO MORE USED PROBABLY
//------------------------------------------------------------------------------
323
void rrc_rlc_register_rrc_NB_IoT (rrc_data_ind_cb_NB_IoT_t rrc_data_indP_NB_IoT, rrc_data_conf_cb_t rrc_data_confP);
324 325 326



327 328 329
//defined in pdcp.c
//FIXME: should go transparent through the PDCP
//--------------------------------------------
330
boolean_t pdcp_data_ind_NB_IoT(
331 332 333 334 335 336 337 338 339 340
  const protocol_ctxt_t* const ctxt_pP,
  const srb_flag_t   srb_flagP,
  const srb1bis_flag_t srb1bis_flag,
  const rb_id_t      rb_idP,
  const sdu_size_t   sdu_buffer_sizeP,
  mem_block_t* const sdu_buffer_pP
);
//---------------------------------------------

//defined in rlc_mac.c
341
void mac_rlc_data_ind_NB_IoT (
342 343 344 345 346 347 348 349 350 351 352 353 354 355
  const module_id_t         module_idP,
  const rnti_t              rntiP,
  const module_id_t         eNB_index,
  const frame_t             frameP,
  const eNB_flag_t          enb_flagP,
//const MBMS_flag_t         MBMS_flagP,
  const logical_chan_id_t   channel_idP,
  char                     *buffer_pP,
  const tb_size_t           tb_sizeP,
  num_tb_t                  num_tbP,
  crc_t                    *crcs_pP);
//-------------------------------------------

//defined in rlc_am.c
356
void rlc_am_mac_data_indication_NB_IoT (
357 358 359 360 361 362 363 364
  const protocol_ctxt_t* const ctxt_pP,
  void * const                 rlc_pP,
  struct mac_data_ind          data_indP
);
//--------------------------------------------

//defined in rlc_mac.c
//called by the schedule_ue_spec for getting SDU to be transmitted from SRB1/SRB1bis and DRBs
365
tbs_size_t mac_rlc_data_req_eNB_NB_IoT(
366 367 368 369 370 371 372 373
  const module_id_t       module_idP,
  const rnti_t            rntiP,
  const eNB_index_t       eNB_index,
  const frame_t           frameP,
  const MBMS_flag_t       MBMS_flagP,
  const logical_chan_id_t channel_idP,
  char             *buffer_pP);
//--------------------------------------------
374 375 376



377
/*-----------eNB procedures (rrc_eNB_nb_iot.c)---------------*/
378

379
//---Initialization--------------
380
void openair_eNB_rrc_on_NB_IoT(
381 382 383
  const protocol_ctxt_t* const ctxt_pP
);

384
void rrc_config_buffer_NB_IoT(
385
  SRB_INFO_NB_IoT* Srb_info,
386 387 388
  uint8_t Lchan_type,
  uint8_t Role
);
389

390
char openair_rrc_eNB_configuration_NB_IoT(
391 392 393
  const module_id_t enb_mod_idP,
  RrcConfigurationReq* configuration
);
394

395 396
//-----------------------------
/**\brief RRC eNB task. (starting of the RRC state machine)
397
   \param void *args_p Pointer on arguments to start the task. */
398
void *rrc_enb_task_NB_IoT(void *args_p);
399 400 401 402

/**\brief Entry routine to decode a UL-CCCH-Message-NB.  Invokes PER decoder and parses message.
   \param ctxt_pP Running context
   \param Srb_info Pointer to SRB0 information structure (buffer, etc.)*/
403
int rrc_eNB_decode_ccch_NB_IoT(
404
  protocol_ctxt_t* const ctxt_pP,
405
  const SRB_INFO_NB_IoT*        const Srb_info,
406 407 408 409 410 411 412
  const int              CC_id
);

/**\brief Entry routine to decode a UL-DCCH-Message-NB.  Invokes PER decoder and parses message.
   \param ctxt_pP Context
   \param Rx_sdu Pointer Received Message
   \param sdu_size Size of incoming SDU*/
413
int rrc_eNB_decode_dcch_NB_IoT(
414 415 416 417 418 419 420 421 422 423
  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
);

/**\brief Generate RRCConnectionReestablishmentReject-NB
   \param ctxt_pP       Running context
   \param ue_context_pP UE context
   \param CC_id         Component Carrier ID*/
424
void rrc_eNB_generate_RRCConnectionReestablishmentReject_NB_IoT(
425
  const protocol_ctxt_t* const ctxt_pP,
426
  rrc_eNB_ue_context_NB_IoT_t*          const ue_context_pP,
427 428 429
  const int                    CC_id
);

430
void rrc_eNB_generate_RRCConnectionReject_NB_IoT(
431
  const protocol_ctxt_t* const ctxt_pP,
432
  rrc_eNB_ue_context_NB_IoT_t*          const ue_context_pP,
433 434 435
  const int                    CC_id
);

436
void rrc_eNB_generate_RRCConnectionSetup_NB_IoT(
437
  const protocol_ctxt_t* const ctxt_pP,
438
  rrc_eNB_ue_context_NB_IoT_t*          const ue_context_pP,
439 440 441
  const int                    CC_id
);

442
void rrc_eNB_process_RRCConnectionReconfigurationComplete_NB_IoT(
443
  const protocol_ctxt_t* const ctxt_pP,
444
  rrc_eNB_ue_context_NB_IoT_t*        ue_context_pP,
445 446 447 448 449
  const uint8_t xid //transaction identifier
);


void //was under ITTI
450
rrc_eNB_reconfigure_DRBs_NB_IoT(const protocol_ctxt_t* const ctxt_pP,
451
			       rrc_eNB_ue_context_NB_IoT_t*  ue_context_pP);
452 453

void //was under ITTI
454
rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_NB_IoT(
455
		const protocol_ctxt_t* const ctxt_pP,
456
	    rrc_eNB_ue_context_NB_IoT_t*          const ue_context_pP
457 458 459
        //no ho state
	     );

460
void rrc_eNB_process_RRCConnectionSetupComplete_NB_IoT(
461
  const protocol_ctxt_t* const ctxt_pP,
462
  rrc_eNB_ue_context_NB_IoT_t*         ue_context_pP,
463 464 465
  RRCConnectionSetupComplete_NB_r13_IEs_t * rrcConnectionSetupComplete_NB
);

466
void rrc_eNB_generate_SecurityModeCommand_NB_IoT(
467
  const protocol_ctxt_t* const ctxt_pP,
468
  rrc_eNB_ue_context_NB_IoT_t*          const ue_context_pP
469 470
);

471
void rrc_eNB_generate_UECapabilityEnquiry_NB_IoT(
472
  const protocol_ctxt_t* const ctxt_pP,
473
  rrc_eNB_ue_context_NB_IoT_t*          const ue_context_pP
474 475
);

476
void rrc_eNB_generate_defaultRRCConnectionReconfiguration_NB_IoT(const protocol_ctxt_t* const ctxt_pP,
477
						                                                     rrc_eNB_ue_context_NB_IoT_t*          const ue_context_pP
478 479
						                                                     //no HO flag
						                                                    );
480 481 482 483


/// Utilities------------------------------------------------

484
void rrc_eNB_free_UE_NB_IoT(
485
		const module_id_t enb_mod_idP,
486
		const struct rrc_eNB_ue_context_NB_IoT_s*        const ue_context_pP
487 488
		);

489
void rrc_eNB_free_mem_UE_context_NB_IoT(
490
  const protocol_ctxt_t*               const ctxt_pP,
491
  struct rrc_eNB_ue_context_NB_IoT_s*         const ue_context_pP
492 493 494 495 496 497 498
);



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

501 502 503

int rrc_init_global_param_NB_IoT(void);

504
//L2_interface.c
505
int8_t mac_rrc_data_req_eNB_NB_IoT(
506 507 508
  const module_id_t Mod_idP,
  const int         CC_id,
  const frame_t     frameP,
509 510
  const frame_t   h_frameP,
  const sub_frame_t   subframeP, //need for the case in which both SIB1-NB_IoT and SIB23-NB_IoT will be scheduled in the same frame
511
  const rb_id_t     Srb_id,
512 513
  uint8_t* const buffer_pP,
  uint8_t   flag
514 515 516 517
);