rlc.h 34.7 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
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
 * 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 22 23 24 25 26 27 28 29 30

/*! \file rlc.h
* \brief This file, and only this file must be included by external code that interact with RLC layer.
* \author GAUTHIER Lionel
* \date 2010-2011
* \version
* \note
* \bug
* \warning
*/
31 32
/** @defgroup _rlc_impl_ RLC 
* @ingroup _oai2
33 34 35 36 37 38 39
* @{
*/
#ifndef __RLC_H__
#    define __RLC_H__

#    include "platform_types.h"
#    include "platform_constants.h"
40
#    include "hashtable.h"
41 42 43 44 45 46
#    include "rlc_am.h"
#    include "rlc_um.h"
#    include "rlc_tm.h"
#    include "rlc_am_structs.h"
#    include "rlc_tm_structs.h"
#    include "rlc_um_structs.h"
47
#    include "LTE_asn_constant.h"
48
#    include "common/utils/LOG/log.h"
49
#    include "mem_block.h"
50
//#    include "PHY/defs.h"
51 52 53 54 55 56 57 58 59
#    include "LTE_RLC-Config.h"
#    include "LTE_DRB-ToAddMod.h"
#    include "LTE_DRB-ToAddModList.h"
#    include "LTE_SRB-ToAddMod.h"
#    include "LTE_SRB-ToAddModList.h"
#    include "LTE_DRB-ToReleaseList.h"

#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0))
#include "LTE_PMCH-InfoList-r9.h"
60 61
#endif

62
typedef uint64_t hash_key_t;
63
#define HASHTABLE_NOT_A_KEY_VALUE ((uint64_t)-1)
64

65 66 67 68 69 70
//-----------------------------------------------------------------------------
#define  RLC_OP_STATUS_OK                1
#define  RLC_OP_STATUS_BAD_PARAMETER     22
#define  RLC_OP_STATUS_INTERNAL_ERROR    2
#define  RLC_OP_STATUS_OUT_OF_RESSOURCES 3

Lionel Gauthier's avatar
Lionel Gauthier committed
71
#define  RLC_MUI_UNDEFINED     (mui_t)0
72

73
#define  RLC_RB_UNALLOCATED    (rb_id_t)0
74
#define  RLC_LC_UNALLOCATED    (logical_chan_id_t)0
75

Lionel Gauthier's avatar
Lionel Gauthier committed
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
//-----------------------------------------------------------------------------
//   PUBLIC RLC CONSTANTS
//-----------------------------------------------------------------------------

typedef enum rlc_confirm_e {
  RLC_SDU_CONFIRM_NO    = 0,
  RLC_SDU_CONFIRM_YES   = 1,
} rlc_confirm_t;

typedef enum rlc_mode_e {
  RLC_MODE_NONE    = 0,
  RLC_MODE_AM      = 1,
  RLC_MODE_UM      = 2,
  RLC_MODE_TM      = 4
} rlc_mode_t;
91 92 93 94 95 96 97

/*! \struct  rlc_info_t
* \brief Structure containing RLC protocol configuration parameters.
*/
typedef volatile struct {
  rlc_mode_t             rlc_mode;
  union {
98 99 100 101
    rlc_am_info_t              rlc_am_info; /*!< \sa rlc_am.h. */
    rlc_tm_info_t              rlc_tm_info; /*!< \sa rlc_tm.h. */
    rlc_um_info_t              rlc_um_info; /*!< \sa rlc_um.h. */
  } rlc;
102 103 104 105 106 107
} rlc_info_t;

/*! \struct  mac_rlc_status_resp_t
* \brief Primitive exchanged between RLC and MAC informing about the buffer occupancy of the RLC protocol instance.
*/
typedef  struct {
108 109 110 111 112
  rlc_buffer_occupancy_t       bytes_in_buffer; /*!< \brief Bytes buffered in RLC protocol instance. */
  rlc_buffer_occupancy_t       pdus_in_buffer;  /*!< \brief Number of PDUs buffered in RLC protocol instance (OBSOLETE). */
  frame_t                      head_sdu_creation_time;           /*!< \brief Head SDU creation time. */
  sdu_size_t                   head_sdu_remaining_size_to_send;  /*!< \brief remaining size of sdu: could be the total size or the remaining size of already segmented sdu */
  boolean_t                    head_sdu_is_segmented;     /*!< \brief 0 if head SDU has not been segmented, 1 if already segmented */
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
} mac_rlc_status_resp_t;


/*! \struct  mac_rlc_max_rx_header_size_t
* \brief Usefull only for debug scenario where we connect 2 RLC protocol instances without the help of the MAC .
*/
typedef struct {
  union {
    struct rlc_am_rx_pdu_management dummy1;
    struct rlc_tm_rx_pdu_management dummy2;
    //struct rlc_um_rx_pdu_management dummy3;
    struct mac_tb_ind dummy4;
    struct mac_rx_tb_management dummy5;
  } dummy;
} mac_rlc_max_rx_header_size_t;

129 130


131 132 133 134
//-----------------------------------------------------------------------------
//   PRIVATE INTERNALS OF RLC
//-----------------------------------------------------------------------------

135 136
#define  RLC_MAX_MBMS_LC (LTE_maxSessionPerPMCH * LTE_maxServiceCount)
#define  RLC_MAX_LC  ((max_val_LTE_DRB_Identity+1)* MAX_MOBILES_PER_ENB)
137

138
void (*rlc_rrc_data_ind)(
139 140 141
                const protocol_ctxt_t* const ctxtP,
                const rb_id_t     rb_idP,
                const sdu_size_t  sdu_sizeP,
142
                const uint8_t   * const sduP);
143

144
void (*rlc_rrc_data_conf)(
145 146 147
                const protocol_ctxt_t* const ctxtP,
                const rb_id_t         rb_idP,
                const mui_t           muiP,
148
                const rlc_tx_status_t statusP);
149 150

typedef void (rrc_data_ind_cb_t)(
151 152 153
  const protocol_ctxt_t* const ctxtP,
  const rb_id_t     rb_idP,
  const sdu_size_t  sdu_sizeP,
154
  const uint8_t   * const sduP);
155 156

typedef void (rrc_data_conf_cb_t)(
157 158 159 160
  const protocol_ctxt_t* const ctxtP,
  const rb_id_t         rb_idP,
  const mui_t           muiP,
  const rlc_tx_status_t statusP);
161 162 163 164 165


/*! \struct  rlc_t
* \brief Structure to be instanciated to allocate memory for RLC protocol instances.
*/
166
typedef struct rlc_union_s {
167 168 169 170 171 172 173
  rlc_mode_t           mode;
  union {
    rlc_am_entity_t  am;
    rlc_um_entity_t  um;
    rlc_tm_entity_t  tm;
  } rlc;
} rlc_union_t;
174

175 176
typedef struct rlc_mbms_s {
  rb_id_t           rb_id;
177 178
  module_id_t       instanciated_instance;
  rlc_um_entity_t   um;
179 180
} rlc_mbms_t;

181 182 183 184 185
typedef struct rlc_mbms_id_s {
  mbms_service_id_t       service_id;
  mbms_session_id_t       session_id;
} rlc_mbms_id_t;

186
#if (LTE_RRC_VERSION < MAKE_VERSION(10, 0, 0))
Lionel Gauthier's avatar
Lionel Gauthier committed
187
#    if !defined(maxServiceCount)
188
//unused arrays rlc_mbms_array_ue rlc_mbms_array_eNB
Lionel Gauthier's avatar
Lionel Gauthier committed
189 190 191
#        define maxServiceCount 1
#    endif
#    if !defined(maxSessionPerPMCH)
192
//unused arrays rlc_mbms_array_ue rlc_mbms_array_eNB
Lionel Gauthier's avatar
Lionel Gauthier committed
193 194 195
#        define maxSessionPerPMCH 1
#    endif
#endif
196 197 198 199
//rlc_mbms_t           rlc_mbms_array_ue[MAX_MOBILES_PER_ENB][maxServiceCount][maxSessionPerPMCH];   // some constants from openair2/RRC/LTE/MESSAGES/asn1_constants.h
//rlc_mbms_t           rlc_mbms_array_eNB[NUMBER_OF_eNB_MAX][maxServiceCount][maxSessionPerPMCH]; // some constants from openair2/RRC/LTE/MESSAGES/asn1_constants.h
rlc_mbms_id_t        rlc_mbms_lcid2service_session_id_ue[MAX_MOBILES_PER_ENB][RLC_MAX_MBMS_LC];    // some constants from openair2/RRC/LTE/MESSAGES/asn1_constants.h
rlc_mbms_id_t        rlc_mbms_lcid2service_session_id_eNB[MAX_eNB][RLC_MAX_MBMS_LC];  // some constants from openair2/RRC/LTE/MESSAGES/asn1_constants.h
200

Lionel Gauthier's avatar
Lionel Gauthier committed
201
#define rlc_mbms_enb_get_lcid_by_rb_id(Enb_mOD,rB_iD) rlc_mbms_rbid2lcid_eNB[Enb_mOD][rB_iD]
Lionel Gauthier's avatar
Lionel Gauthier committed
202
;
203 204

#define rlc_mbms_enb_set_lcid_by_rb_id(Enb_mOD,rB_iD,lOG_cH_iD) do { \
Lionel Gauthier's avatar
Lionel Gauthier committed
205
            rlc_mbms_rbid2lcid_eNB[Enb_mOD][rB_iD] = lOG_cH_iD; \
206 207
        } while (0);

Lionel Gauthier's avatar
Lionel Gauthier committed
208
#define rlc_mbms_ue_get_lcid_by_rb_id(uE_mOD,rB_iD) rlc_mbms_rbid2lcid_ue[uE_mOD][rB_iD]
209 210

#define rlc_mbms_ue_set_lcid_by_rb_id(uE_mOD,rB_iD,lOG_cH_iD) do { \
211
            AssertFatal(rB_iD<NB_RB_MBMS_MAX, "INVALID RB ID %u", rB_iD); \
Lionel Gauthier's avatar
Lionel Gauthier committed
212
            rlc_mbms_rbid2lcid_ue[uE_mOD][rB_iD] = lOG_cH_iD; \
213 214
        } while (0);

215 216
logical_chan_id_t    rlc_mbms_rbid2lcid_ue [MAX_MOBILES_PER_ENB][NB_RB_MBMS_MAX];              /*!< \brief Pairing logical channel identifier with radio bearer identifer. */
logical_chan_id_t    rlc_mbms_rbid2lcid_eNB[MAX_eNB][NB_RB_MBMS_MAX];              /*!< \brief Pairing logical channel identifier with radio bearer identifer. */
217 218


219
#define RLC_COLL_KEY_VALUE(eNB_iD, rNTI, iS_eNB, rB_iD, iS_sRB) \
220
   ((hash_key_t)eNB_iD             | \
221 222 223
    (((hash_key_t)(rNTI))   << 8)  | \
    (((hash_key_t)(iS_eNB)) << 24) | \
    (((hash_key_t)(rB_iD))  << 25) | \
224 225 226 227 228 229 230 231 232 233 234 235
    (((hash_key_t)(iS_sRB)) << 33) | \
    (((hash_key_t)(0x05))   << 34))

// index to the same RLC entity as RLC_COLL_KEY_VALUE(), but using LC_id instead
// the hidden last key indicates if this is a hash-key with RB_id (0x05) or LC_id (0x0a)
#define RLC_COLL_KEY_LCID_VALUE(eNB_iD, rNTI, iS_eNB, lC_iD, iS_sRB) \
   ((hash_key_t)eNB_iD             | \
    (((hash_key_t)(rNTI))   << 8)  | \
    (((hash_key_t)(iS_eNB)) << 24) | \
    (((hash_key_t)(lC_iD))  << 25) | \
    (((hash_key_t)(iS_sRB)) << 33) | \
    (((hash_key_t)(0x0a))   << 34))
236

237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
#define RLC_COLL_KEY_SOURCE_DEST_VALUE(eNB_iD, rNTI, iS_eNB, lC_iD, sOURCE_iD, dEST_iD, iS_sRB) \
   ((hash_key_t)eNB_iD             | \
    (((hash_key_t)(rNTI))   << 8)  | \
    (((hash_key_t)(iS_eNB)) << 24) | \
    (((hash_key_t)(lC_iD))  << 25) | \
    (((hash_key_t)(dEST_iD)) << 33) | \
    (((hash_key_t)(0x05))   << 57))

#define RLC_COLL_KEY_LCID_SOURCE_DEST_VALUE(eNB_iD, rNTI, iS_eNB, lC_iD, sOURCE_iD, dEST_iD, iS_sRB) \
   ((hash_key_t)eNB_iD             | \
    (((hash_key_t)(rNTI))   << 8)  | \
    (((hash_key_t)(iS_eNB)) << 24) | \
    (((hash_key_t)(lC_iD))  << 25) | \
    (((hash_key_t)(dEST_iD)) << 33) | \
    (((hash_key_t)(0x0a))   << 57))


254 255
// service id max val is maxServiceCount = 16 (asn1_constants.h)

256
#define RLC_COLL_KEY_MBMS_VALUE(eNB_iD, rNTI, iS_eNB, sERVICE_ID, sESSION_ID) \
257
   ((hash_key_t)eNB_iD             | \
258 259 260 261
    (((hash_key_t)(rNTI))       << 8)  | \
    (((hash_key_t)(iS_eNB))     << 24) | \
    (((hash_key_t)(sERVICE_ID)) << 32) | \
    (((hash_key_t)(sESSION_ID)) << 37) | \
262 263
    (((hash_key_t)(0x0000000000000001))  << 63))

264
hash_table_t  *rlc_coll_p;
265

266 267 268 269 270 271
/*! \fn tbs_size_t mac_rlc_serialize_tb (char* bufferP, list_t transport_blocksP)
* \brief  Serialize a list of transport blocks coming from RLC in order to be processed by MAC.
* \param[in]  bufferP                 Memory area where the transport blocks have to be serialized.
* \param[in]  transport_blocksP       List of transport blocks.
* \return     The amount of bytes that have been written due to serialization.
*/
272
tbs_size_t            mac_rlc_serialize_tb   (char*, list_t);
273 274 275 276 277 278 279 280 281

/*! \fn struct mac_data_ind mac_rlc_deserialize_tb (char* bufferP, tb_size_t tb_sizeP, num_tb_t num_tbP, crc_t *crcsP)
* \brief  Serialize a list of transport blocks coming from RLC in order to be processed by MAC.
* \param[in]  bufferP       Memory area where the transport blocks are serialized.
* \param[in]  tb_sizeP      Size of transport blocks.
* \param[in]  num_tbP       Number of transport blocks.
* \param[in]  crcsP         Array of CRC for each transport block.
* \return     A mac_data_ind structure containing a list of transport blocks.
*/
282
struct mac_data_ind   mac_rlc_deserialize_tb (char*, tb_size_t, num_tb_t, crc_t *);
283 284 285 286 287


//-----------------------------------------------------------------------------
//   PUBLIC INTERFACE WITH RRC
//-----------------------------------------------------------------------------
288
#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
289
/*! \fn rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, const SRB_ToAddMod_t* const srb2addmod, const DRB_ToAddModList_t* const drb2add_listP, const DRB_ToReleaseList_t*  const drb2release_listP, const PMCH_InfoList_r9_t * const pmch_info_listP)
290
* \brief  Function for RRC to configure a Radio Bearer.
291
* \param[in]  ctxtP              Running context.
292 293 294 295 296 297
* \param[in]  srb2add_listP      SRB configuration list to be created.
* \param[in]  drb2add_listP      DRB configuration list to be created.
* \param[in]  drb2release_listP  DRB configuration list to be released.
* \param[in]  pmch_info_listP    eMBMS pmch info list to be created.
* \return     A status about the processing, OK or error code.
*/
298
rlc_op_status_t rrc_rlc_config_asn1_req (
299
                  const protocol_ctxt_t* const,
300 301 302 303
                  const LTE_SRB_ToAddModList_t* const ,
                  const LTE_DRB_ToAddModList_t* const ,
                  const LTE_DRB_ToReleaseList_t* const ,
                  const LTE_PMCH_InfoList_r9_t * const pmch_info_listP ,
304
                  const uint32_t ,
305
                  const uint32_t );
306
#else
307
/*! \fn rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t* const ctxtP, const SRB_ToAddModList_t* const srb2add_listP, const DRB_ToAddModList_t* const drb2add_listP, const DRB_ToReleaseList_t* const drb2release_listP)
308
* \brief  Function for RRC to configure a Radio Bearer.
309
* \param[in]  ctxtP              Running context.
310 311 312 313 314
* \param[in]  srb2add_listP      SRB configuration list to be created.
* \param[in]  drb2add_listP      DRB configuration list to be created.
* \param[in]  drb2release_listP  DRB configuration list to be released.
* \return     A status about the processing, OK or error code.
*/
315
rlc_op_status_t rrc_rlc_config_asn1_req (
316
                  const protocol_ctxt_t* const,
317 318 319
                  const LTE_SRB_ToAddModList_t* const ,
                  const LTE_DRB_ToAddModList_t* const ,
                  const LTE_DRB_ToReleaseList_t* const );
320 321
#endif

322 323 324 325 326 327

/*! \fn void rb_free_rlc_union (void *rlcu_pP)
 * \brief  Free the rlc memory contained in the RLC embedded in the rlc_union_t
 *  struct pointed by of the rlcu_pP parameter. Free the rlc_union_t struct also.
 * \param[in]  rlcu_pP          Pointer on the rlc_union_t struct.
 */
328 329
void
               rb_free_rlc_union (void *rlcu_pP);
330 331


332
/*! \fn rlc_op_status_t rrc_rlc_remove_ue   (const protocol_ctxt_t* const ctxtP)
Lionel Gauthier's avatar
 
Lionel Gauthier committed
333
 * \brief  Remove all RLC protocol instances from all radio bearers allocated to a UE.
334
 * \param[in]  ctxtP              Running context.
Lionel Gauthier's avatar
 
Lionel Gauthier committed
335 336
 * \return     A status about the processing, OK or error code.
*/
337
rlc_op_status_t rrc_rlc_remove_ue (const protocol_ctxt_t* const);
Lionel Gauthier's avatar
 
Lionel Gauthier committed
338 339


340
/*! \fn rlc_op_status_t rrc_rlc_remove_rlc   (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, const  rb_id_t rb_idP)
341
* \brief  Remove a RLC protocol instance from a radio bearer.
342 343 344 345
* \param[in]  ctxtP              Running context.
* \param[in]  srb_flagP          Flag to indicate SRB (1) or DRB (0)
* \param[in]  MBMS_flag          Flag to indicate whether this is an MBMS service (1) or not (0)
* \param[in]  rb_idP             Radio bearer identifier.
346 347
* \return     A status about the processing, OK or error code.
*/
348
rlc_op_status_t rrc_rlc_remove_rlc   (const protocol_ctxt_t* const, const srb_flag_t, const MBMS_flag_t, const  rb_id_t );
349

350
/*! \fn rlc_union_t*  rrc_rlc_add_rlc   (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, const  MBMS_flag_t MBMS_flagP, const  rb_id_t rb_idP, logical_chan_id_t chan_idP, rlc_mode_t rlc_modeP)
351
* \brief  Add a RLC protocol instance to a radio bearer.
352 353 354 355 356 357
* \param[in]  ctxtP              Running context.
* \param[in]  srb_flagP          Flag to indicate SRB (1) or DRB (0)
* \param[in]  MBMS_flag          Flag to indicate whether this is an MBMS service (1) or not (0)
* \param[in]  rb_idP             Radio bearer identifier.
* \param[in]  chan_idP           Logical channel identifier.
* \param[in]  rlc_modeP          Mode of RLC (AM, UM, TM).
358 359
* \return     A status about the processing, OK or error code.
*/
360
rlc_union_t*  rrc_rlc_add_rlc      (const protocol_ctxt_t* const, const srb_flag_t,  const  MBMS_flag_t MBMS_flagP, const  rb_id_t, logical_chan_id_t, rlc_mode_t
361
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
362 363 364
  ,const uint32_t  sourceL2Id,
  const uint32_t  destinationL2Id
#endif
365
);
366 367

/*! \fn rlc_op_status_t rrc_rlc_config_req (
368
     const protocol_ctxt_t* const ctxtP,
369 370 371 372 373
     const srb_flag_t   srb_flagP,
     const MBMS_flag_t  MBMS_flagP,
     config_action_t actionP,
     const  rb_id_t rb_idP,
     rlc_info_t rlc_infoP)
374
* \brief  Function for RRC to configure a Radio Bearer.
375
* \param[in]  ctxtP            Running context.
376 377
* \param[in]  srb_flagP        Flag to indicate SRB (1) or DRB (0)
* \param[in]  MBMS_flag        Flag to indicate whether this is an MBMS service (1) or not (0)
378 379 380 381 382
* \param[in]  actionP          Action for this radio bearer (add, modify, remove).
* \param[in]  rb_idP           Radio bearer identifier.
* \param[in]  rlc_infoP        RLC configuration parameters issued from Radio Resource Manager.
* \return     A status about the processing, OK or error code.
*/
383
rlc_op_status_t rrc_rlc_config_req   (
384 385 386 387 388
                  const protocol_ctxt_t* const,
                  const srb_flag_t,
                  const MBMS_flag_t,
                  config_action_t,
                  const  rb_id_t,
389
                  rlc_info_t );
390 391

/*! \fn rlc_op_status_t rrc_rlc_data_req     (const protocol_ctxt_t* const ctxtP, const  MBMS_flag_t MBMS_flagP, const  rb_id_t rb_idP, mui_t muiP, confirm_t confirmP, sdu_size_t sdu_sizeP, char* sduP)
392
* \brief  Function for RRC to send a SDU through a Signalling Radio Bearer.
393
* \param[in]  ctxtP            Running context.
394 395 396 397 398 399 400 401
* \param[in]  MBMS_flag        Flag to indicate whether this is an MBMS service (1) or not (0)
* \param[in]  rb_idP           Radio bearer identifier.
* \param[in]  muiP             Message Unit identifier.
* \param[in]  confirmP         Boolean, is confirmation requested.
* \param[in]  sdu_sizeP        Size of SDU in bytes.
* \param[in]  sduP             SDU.
* \return     A status about the processing, OK or error code.
*/
402
rlc_op_status_t rrc_rlc_data_req     (const protocol_ctxt_t* const , const  MBMS_flag_t, const  rb_id_t, mui_t, confirm_t, sdu_size_t, char *);
403

404
/*! \fn void  rrc_rlc_register_rrc ( void (*rrc_data_indP)  (const protocol_ctxt_t* const ctxtP, const  rb_id_t rb_idP, sdu_size_t sdu_sizeP, char* sduP), void (*rrc_data_confP) (const protocol_ctxt_t* const ctxtP, const  rb_id_t rb_idP, mui_t muiP, rlc_tx_status_t statusP)
405 406 407 408
* \brief  This function is called by RRC to register its DATA-INDICATE and DATA-CONFIRM handlers to RLC layer.
* \param[in]  rrc_data_indP       Pointer on RRC data indicate function.
* \param[in]  rrc_data_confP      Pointer on RRC data confirm callback function.
*/
409
void rrc_rlc_register_rrc (rrc_data_ind_cb_t rrc_data_indP, rrc_data_conf_cb_t rrc_data_confP);
410 411 412 413

//-----------------------------------------------------------------------------
//   PUBLIC INTERFACE WITH MAC
//-----------------------------------------------------------------------------
414
/*! \fn tbs_size_t mac_rlc_data_req     (const module_id_t mod_idP, const rnti_t rntiP, const frame_t frameP, const  MBMS_flag_t MBMS_flagP, logical_chan_id_t rb_idP, char* bufferP)
415
* \brief    Interface with MAC layer, map data request to the RLC corresponding to the radio bearer.
416 417
* \param [in]     mod_idP          Virtualized module identifier.
* \param [in]     rntiP            UE identifier.
418 419
* \param [in]     frameP            Frame index
* \param [in]     eNB_flagP        Flag to indicate eNB (1) or UE (0)
420 421
* \param [in]     MBMS_flagP       Flag to indicate whether this is the MBMS service (1) or not (0)
* \param [in]     rb_idP           Radio bearer identifier.
422
* \param [in]     tb_sizeP         Available Tx TBS in bytes. For UE only.
423 424 425
* \param [in,out] bufferP          Memory area to fill with the bytes requested by MAC.
* \return     A status about the processing, OK or error code.
*/
426
tbs_size_t            mac_rlc_data_req     (const module_id_t, const rnti_t, const eNB_index_t, const frame_t, const  eNB_flag_t, const  MBMS_flag_t, logical_chan_id_t, const tb_size_t,char*
427
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
428 429 430
                                                           ,const uint32_t sourceL2Id
                                                           ,const uint32_t destinationL2Id
#endif
431
);
432

433
/*! \fn void mac_rlc_data_ind     (const module_id_t mod_idP, const rnti_t rntiP, const frame_t frameP, const  eNB_flag_t eNB_flagP, const  MBMS_flag_t MBMS_flagP, logical_chan_id_t rb_idP, uint32_t frameP, char* bufferP, tb_size_t tb_sizeP, num_tb_t num_tbP, crc_t *crcs)
434
* \brief    Interface with MAC layer, deserialize the transport blocks sent by MAC, then map data indication to the RLC instance corresponding to the radio bearer identifier.
435 436
* \param[in]  mod_idP          Virtualized module identifier.
* \param[in]  rntiP            UE identifier.
437
* \param[in]  frameP            Frame index
438 439 440 441 442 443 444 445
* \param[in]  eNB_flagP        Flag to indicate eNB (1) or UE (0)
* \param[in]  MBMS_flagP       Flag to indicate whether this is the MBMS service (1) or not (0)
* \param[in]  rb_idP           Radio bearer identifier.
* \param[in]  bufferP          Memory area containing the transport blocks sent by MAC.
* \param[in]  tb_sizeP         Size of a transport block in bits.
* \param[in]  num_tbP          Number of transport blocks.
* \param[in]  crcs             Array of CRC decoding.
*/
446 447
void                  mac_rlc_data_ind     (const module_id_t, const rnti_t, const eNB_index_t,const frame_t, const  eNB_flag_t, const  MBMS_flag_t, logical_chan_id_t, char*, tb_size_t, num_tb_t,
               crc_t* );
448

449
/*! \fn mac_rlc_status_resp_t mac_rlc_status_ind     (const module_id_t mod_idP, const rnti_t rntiP, const frame_t frameP, const sub_frame_t subframeP, const  eNB_flag_t eNB_flagP, const  MBMS_flag_t MBMS_flagP, logical_chan_id_t rb_idP, tb_size_t tb_sizeP)
450
* \brief    Interface with MAC layer, request and set the number of bytes scheduled for transmission by the RLC instance corresponding to the radio bearer identifier.
451 452
* \param[in]  mod_idP          Virtualized module identifier.
* \param[in]  rntiP            UE identifier.
453
* \param[in]  frameP            Frame index.
454
* \param[in]  subframeP         SubFrame index.
455
* \param[in]  eNB_flagP         Flag to indicate eNB operation (1 true, 0 false)
456 457 458 459 460
* \param[in]  MBMS_flagP       Flag to indicate whether this is the MBMS service (1) or not (0)
* \param[in]  rb_idP           Radio bearer identifier.
* \param[in]  tb_sizeP         Size of a transport block set in bytes.
* \return     The maximum number of bytes that the RLC instance can send in the next transmission sequence.
*/
461
mac_rlc_status_resp_t mac_rlc_status_ind   (const module_id_t, const rnti_t, const eNB_index_t, const frame_t, const sub_frame_t, const  eNB_flag_t, const  MBMS_flag_t, logical_chan_id_t, tb_size_t
462
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
463 464 465
                                                           ,const uint32_t sourceL2Id
                                                           ,const uint32_t destinationL2Id
#endif
466
  );
467 468 469 470 471 472 473 474 475 476 477

/*! \fn rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind(const module_id_t module_idP, const rnti_t rntiP, const eNB_index_t eNB_index, const frame_t frameP, const sub_frame_t subframeP,const eNB_flag_t enb_flagP, const logical_chan_id_t channel_idP)
* \brief    Interface with MAC layer, UE only: request and get the number of bytes scheduled for transmission by the RLC instance corresponding to the radio bearer identifier.
* \param[in]  mod_idP          Virtualized module identifier.
* \param[in]  rntiP            UE identifier.
* \param[in]  frameP            Frame index.
* \param[in]  subframeP         SubFrame index.
* \param[in]  eNB_flagP         Flag to indicate eNB operation (1 true, 0 false)
* \param[in]  channel_idP       Logical Channel identifier.
* \return     The maximum number of bytes that the RLC instance can send in the next transmission sequence.
*/
478
rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind(const module_id_t, const rnti_t, const eNB_index_t, const frame_t, const sub_frame_t, const eNB_flag_t, const logical_chan_id_t );
479 480 481 482 483 484 485 486 487 488
//-----------------------------------------------------------------------------
//   RLC methods
//-----------------------------------------------------------------------------
/*
 * Prints incoming byte stream in hexadecimal and readable form
 *
 * @param componentP Component identifier, see macros defined in UTIL/LOG/log.h
 * @param dataP      Pointer to data buffer to be displayed
 * @param sizeP      Number of octets in data buffer
 */
489
void rlc_util_print_hex_octets(
490 491
             const comp_name_t componentP,
             unsigned char* const dataP,
492
             const signed long sizeP);
493 494 495



496
/*! \fn rlc_op_status_t rlc_data_req     (const protocol_ctxt_t* const ctxtP, const  srb_flag_t srb_flagP,  const  MBMS_flag_t MBMS_flagP, const  rb_id_t rb_idP, mui_t muiP, confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sduP)
497
* \brief    Interface with higher layers, map request to the RLC corresponding to the radio bearer.
498
* \param[in]  ctxtP            Running context.
499
* \param[in]  srb_flagP        Flag to indicate SRB (1) or DRB (0)
500 501 502 503 504 505 506 507
* \param[in]  MBMS_flagP       Flag to indicate whether this is the MBMS service (1) or not (0)
* \param[in]  rb_idP           Radio bearer identifier.
* \param[in]  muiP             Message Unit identifier.
* \param[in]  confirmP         Boolean, is confirmation requested.
* \param[in]  sdu_sizeP        Size of SDU in bytes.
* \param[in]  sduP             SDU.
* \return     A status about the processing, OK or error code.
*/
508
rlc_op_status_t rlc_data_req     (
509 510 511 512 513 514 515
             const protocol_ctxt_t* const,
             const  srb_flag_t,
             const  MBMS_flag_t ,
             const  rb_id_t ,
             const  mui_t ,
             const confirm_t ,
             const sdu_size_t ,
516
             mem_block_t * const
517
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
518 519 520
             ,const uint32_t * const
             ,const uint32_t * const
#endif
521
             );
522 523

/*! \fn void rlc_data_ind     (const protocol_ctxt_t* const ctxtP, const  srb_flag_t srb_flagP, const  MBMS_flag_t MBMS_flagP, const  rb_id_t rb_idP, const sdu_size_t sdu_sizeP, mem_block_t* sduP) {
524
* \brief    Interface with higher layers, route SDUs coming from RLC protocol instances to upper layer instance.
525
* \param[in]  ctxtP            Running context.
526
* \param[in]  srb_flagP        Flag to indicate SRB (1) or DRB (0)
527 528 529 530 531
* \param[in]  MBMS_flagP       Flag to indicate whether this is the MBMS service (1) or not (0)
* \param[in]  rb_idP           Radio bearer identifier.
* \param[in]  sdu_sizeP        Size of SDU in bytes.
* \param[in]  sduP             SDU.
*/
532
void rlc_data_ind(
533 534 535 536 537
             const protocol_ctxt_t* const,
             const srb_flag_t,
             const MBMS_flag_t ,
             const rb_id_t,
             const sdu_size_t,
538
             mem_block_t* const);
539 540 541


/*! \fn void rlc_data_conf     (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, const  rb_id_t rb_idP, const mui_t muiP, const rlc_tx_status_t statusP)
542
* \brief    Interface with higher layers, confirm to upper layer the transmission status for a SDU stamped with a MUI, scheduled for transmission.
543
* \param[in]  ctxtP            Running context.
544
* \param[in]  srb_flagP        Flag to indicate SRB (1) or DRB (0)
545 546 547 548
* \param[in]  rb_idP           Radio bearer identifier.
* \param[in]  muiP             Message Unit identifier.
* \param[in]  statusP          Status of the transmission (RLC_SDU_CONFIRM_YES, RLC_SDU_CONFIRM_NO).
*/
549
void rlc_data_conf(
550 551 552 553
             const protocol_ctxt_t* const,
             const  srb_flag_t,
             const  rb_id_t,
             const mui_t,
554
             const rlc_tx_status_t );
555 556


557
/*! \fn rlc_op_status_t rlc_stat_req     (
558
                        const protocol_ctxt_t* const ctxtP,
559 560
                        const  srb_flag_t    srb_flagP,
                        const  rb_id_t       rb_idP,
561 562
                        unsigned int* stat_rlc_mode,
			unsigned int* stat_tx_pdcp_sdu,
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590
                        unsigned int* stat_tx_pdcp_bytes,
                        unsigned int* stat_tx_pdcp_sdu_discarded,
                        unsigned int* stat_tx_pdcp_bytes_discarded,
                        unsigned int* stat_tx_data_pdu,
                        unsigned int* stat_tx_data_bytes,
                        unsigned int* stat_tx_retransmit_pdu_by_status,
                        unsigned int* stat_tx_retransmit_bytes_by_status,
                        unsigned int* stat_tx_retransmit_pdu,
                        unsigned int* stat_tx_retransmit_bytes,
                        unsigned int* stat_tx_control_pdu,
                        unsigned int* stat_tx_control_bytes,
                        unsigned int* stat_rx_pdcp_sdu,
                        unsigned int* stat_rx_pdcp_bytes,
                        unsigned int* stat_rx_data_pdus_duplicate,
                        unsigned int* stat_rx_data_bytes_duplicate,
                        unsigned int* stat_rx_data_pdu,
                        unsigned int* stat_rx_data_bytes,
                        unsigned int* stat_rx_data_pdu_dropped,
                        unsigned int* stat_rx_data_bytes_dropped,
                        unsigned int* stat_rx_data_pdu_out_of_window,
                        unsigned int* stat_rx_data_bytes_out_of_window,
                        unsigned int* stat_rx_control_pdu,
                        unsigned int* stat_rx_control_bytes,
                        unsigned int* stat_timer_reordering_timed_out,
                        unsigned int* stat_timer_poll_retransmit_timed_out,
                        unsigned int* stat_timer_status_prohibit_timed_out)

* \brief    Request RLC statistics of a particular radio bearer.
591
* \param[in]  ctxtP                Running context.
592
* \param[in]  srb_flagP            Flag to indicate signalling radio bearer (1) or data radio bearer (0).
593
* \param[in]  rb_idP                       .
594
* \param[out] stat_rlc_mode                        RLC mode 
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623
* \param[out] stat_tx_pdcp_sdu                     Number of SDUs coming from upper layers.
* \param[out] stat_tx_pdcp_bytes                   Number of bytes coming from upper layers.
* \param[out] stat_tx_pdcp_sdu_discarded           Number of discarded SDUs coming from upper layers.
* \param[out] stat_tx_pdcp_bytes_discarded         Number of discarded bytes coming from upper layers.
* \param[out] stat_tx_data_pdu                     Number of transmitted data PDUs to lower layers.
* \param[out] stat_tx_data_bytes                   Number of transmitted data bytes to lower layers.
* \param[out] stat_tx_retransmit_pdu_by_status     Number of re-transmitted data PDUs due to status reception.
* \param[out] stat_tx_retransmit_bytes_by_status   Number of re-transmitted data bytes due to status reception.
* \param[out] stat_tx_retransmit_pdu               Number of re-transmitted data PDUs to lower layers.
* \param[out] stat_tx_retransmit_bytes             Number of re-transmitted data bytes to lower layers.
* \param[out] stat_tx_control_pdu                  Number of transmitted control PDUs to lower layers.
* \param[out] stat_tx_control_bytes                Number of transmitted control bytes to lower layers.
* \param[out] stat_rx_pdcp_sdu                     Number of SDUs delivered to upper layers.
* \param[out] stat_rx_pdcp_bytes                   Number of bytes delivered to upper layers.
* \param[out] stat_rx_data_pdus_duplicate          Number of duplicate PDUs received.
* \param[out] stat_rx_data_bytes_duplicate         Number of duplicate bytes received.
* \param[out] stat_rx_data_pdu                     Number of received PDUs from lower layers.
* \param[out] stat_rx_data_bytes                   Number of received bytes from lower layers.
* \param[out] stat_rx_data_pdu_dropped             Number of received PDUs from lower layers, then dropped.
* \param[out] stat_rx_data_bytes_dropped           Number of received bytes from lower layers, then dropped.
* \param[out] stat_rx_data_pdu_out_of_window       Number of data PDUs received out of the receive window.
* \param[out] stat_rx_data_bytes_out_of_window     Number of data bytes received out of the receive window.
* \param[out] stat_rx_control_pdu                  Number of control PDUs received.
* \param[out] stat_rx_control_bytes                Number of control bytes received.
* \param[out] stat_timer_reordering_timed_out      Number of times the timer "reordering" has timed-out.
* \param[out] stat_timer_poll_retransmit_timed_out Number of times the timer "poll_retransmit" has timed-out.
* \param[out] stat_timer_status_prohibit_timed_out Number of times the timer "status_prohibit" has timed-out.
*/

624
rlc_op_status_t rlc_stat_req     (
625 626 627
             const protocol_ctxt_t* const ctxtP,
             const srb_flag_t    srb_flagP,
             const rb_id_t       rb_idP,
628 629
             unsigned int* const stat_rlc_mode,
	     unsigned int* const stat_tx_pdcp_sdu,
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654
             unsigned int* const stat_tx_pdcp_bytes,
             unsigned int* const stat_tx_pdcp_sdu_discarded,
             unsigned int* const stat_tx_pdcp_bytes_discarded,
             unsigned int* const stat_tx_data_pdu,
             unsigned int* const stat_tx_data_bytes,
             unsigned int* const stat_tx_retransmit_pdu_by_status,
             unsigned int* const stat_tx_retransmit_bytes_by_status,
             unsigned int* const stat_tx_retransmit_pdu,
             unsigned int* const stat_tx_retransmit_bytes,
             unsigned int* const stat_tx_control_pdu,
             unsigned int* const stat_tx_control_bytes,
             unsigned int* const stat_rx_pdcp_sdu,
             unsigned int* const stat_rx_pdcp_bytes,
             unsigned int* const stat_rx_data_pdus_duplicate,
             unsigned int* const stat_rx_data_bytes_duplicate,
             unsigned int* const stat_rx_data_pdu,
             unsigned int* const stat_rx_data_bytes,
             unsigned int* const stat_rx_data_pdu_dropped,
             unsigned int* const stat_rx_data_bytes_dropped,
             unsigned int* const stat_rx_data_pdu_out_of_window,
             unsigned int* const stat_rx_data_bytes_out_of_window,
             unsigned int* const stat_rx_control_pdu,
             unsigned int* const stat_rx_control_bytes,
             unsigned int* const stat_timer_reordering_timed_out,
             unsigned int* const stat_timer_poll_retransmit_timed_out,
655
             unsigned int* const stat_timer_status_prohibit_timed_out);
656

Cedric Roux's avatar
Cedric Roux committed
657
/*! \fn int rlc_module_init(int enb_flag)
658 659
* \brief    RAZ the memory of the RLC layer, initialize the memory pool manager (mem_block_t structures mainly used in RLC module).
*/
Cedric Roux's avatar
Cedric Roux committed
660
int rlc_module_init(int enb_flag);
661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685

/** @} */

#define RLC_FG_COLOR_BLACK            "\e[0;30m"
#define RLC_FG_COLOR_RED              "\e[0;31m"
#define RLC_FG_COLOR_GREEN            "\e[0;32m"
#define RLC_FG_COLOR_ORANGE           "\e[0;33m"
#define RLC_FG_COLOR_BLUE             "\e[0;34m"
#define RLC_FG_COLOR_MAGENTA          "\e[0;35m"
#define RLC_FG_COLOR_CYAN             "\e[0;36m"
#define RLC_FG_COLOR_GRAY_BLACK       "\e[0;37m"
#define RLC_FG_COLOR_DEFAULT          "\e[0;39m"
#define RLC_FG_BRIGHT_COLOR_DARK_GRAY "\e[1;30m"
#define RLC_FG_BRIGHT_COLOR_RED       "\e[1;31m"
#define RLC_FG_BRIGHT_COLOR_GREEN     "\e[1;32m"
#define RLC_FG_BRIGHT_COLOR_YELLOW    "\e[1;33m"
#define RLC_FG_BRIGHT_COLOR_BLUE      "\e[1;34m"
#define RLC_FG_BRIGHT_COLOR_MAGENTA   "\e[1;35m"
#define RLC_FG_BRIGHT_COLOR_CYAN      "\e[1;36m"
#define RLC_FG_BRIGHT_COLOR_WHITE     "\e[1;37m"
#define RLC_FG_BRIGHT_COLOR_DEFAULT   "\e[0;39m"
#define RLC_REVERSE_VIDEO             "\e[7m"
#define RLC_NORMAL_VIDEO              "\e[27m"

#endif