rlc.h 33.2 KB
Newer Older
1
/*******************************************************************************
gauthier's avatar
gauthier committed
2 3
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom
4

gauthier's avatar
gauthier committed
5 6 7 8
    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.
9 10


gauthier's avatar
gauthier committed
11 12 13 14
    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.
15

gauthier's avatar
gauthier committed
16 17 18 19
    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/>.
20

gauthier's avatar
gauthier committed
21 22 23
  Contact Information
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
24
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr
gauthier's avatar
gauthier committed
25

ghaddab's avatar
ghaddab committed
26
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
gauthier's avatar
gauthier committed
27 28

 *******************************************************************************/
29 30 31 32 33 34 35 36 37
/*! \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
*/
38 39
/** @defgroup _rlc_impl_ RLC 
* @ingroup _oai2
40 41 42 43 44 45 46
* @{
*/
#ifndef __RLC_H__
#    define __RLC_H__

#    include "platform_types.h"
#    include "platform_constants.h"
47
#    include "hashtable.h"
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
#    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"
#    include "asn1_constants.h"
#    include "UTIL/LOG/log.h"
#    include "mem_block.h"
#    include "PHY/defs.h"
#    include "RLC-Config.h"
#    include "DRB-ToAddMod.h"
#    include "DRB-ToAddModList.h"
#    include "SRB-ToAddMod.h"
#    include "SRB-ToAddModList.h"
63 64
#    include "DRB-ToReleaseList.h"

65 66 67 68
#ifdef Rel10
#include "PMCH-InfoList-r9.h"
#endif

69 70
#ifdef CMAKER
typedef uint64_t hash_key_t;
71
#define HASHTABLE_NOT_A_KEY_VALUE ((uint64_t)-1)
72
#endif
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
//-----------------------------------------------------------------------------
#    ifdef RLC_MAC_C
#        define private_rlc_mac(x) x
#        define public_rlc_mac(x) x
#    else
#        define private_rlc_mac(x)
#        define public_rlc_mac(x) extern x
#    endif

#    ifdef RLC_MPLS_C
#        define private_rlc_mpls(x) x
#        define public_rlc_mpls(x) x
#    else
#        define private_rlc_mpls(x)
#        define public_rlc_mpls(x) extern x
#    endif

#    ifdef RLC_RRC_C
#        define private_rlc_rrc(x) x
#        define public_rlc_rrc(x) x
#    else
#        define private_rlc_rrc(x)
#        define public_rlc_rrc(x) extern x
#    endif

#    ifdef RLC_C
#        define private_rlc(x) x
#        define protected_rlc(x) x
#        define public_rlc(x) x
#    else
#        define private_rlc(x)
#        if defined(RLC_MAC_C) || defined(RLC_MPLS_C) || defined(RLC_RRC_C) || defined(RLC_AM_C) || defined(RLC_TM_C) || defined(RLC_UM_C) || defined (PDCP_C)
#            define protected_rlc(x) extern x
#        else
#            define protected_rlc(x)
#        endif
#        define public_rlc(x) extern x
#    endif

112

113 114 115 116 117 118
//-----------------------------------------------------------------------------
#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

gauthier's avatar
gauthier committed
119
#define  RLC_MUI_UNDEFINED     (mui_t)0
120

121
#define  RLC_RB_UNALLOCATED    (rb_id_t)0
122
#define  RLC_LC_UNALLOCATED    (logical_chan_id_t)0
123

gauthier's avatar
gauthier committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
//-----------------------------------------------------------------------------
//   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;
139 140 141 142 143 144 145

/*! \struct  rlc_info_t
* \brief Structure containing RLC protocol configuration parameters.
*/
typedef volatile struct {
  rlc_mode_t             rlc_mode;
  union {
146 147 148 149
    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;
150 151 152 153 154 155
} 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 {
156 157 158 159 160
  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 */
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
} 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;

177 178


179 180 181 182
//-----------------------------------------------------------------------------
//   PRIVATE INTERNALS OF RLC
//-----------------------------------------------------------------------------

183
#define  RLC_MAX_MBMS_LC (maxSessionPerPMCH * maxServiceCount)
184
#define  RLC_MAX_LC  ((max_val_DRB_Identity+1)* NUMBER_OF_UE_MAX)
185

186
protected_rlc(void (*rlc_rrc_data_ind)(
187 188 189
                const protocol_ctxt_t* const ctxtP,
                const rb_id_t     rb_idP,
                const sdu_size_t  sdu_sizeP,
190
                const uint8_t   * const sduP);)
191 192

protected_rlc(void (*rlc_rrc_data_conf)(
193 194 195 196
                const protocol_ctxt_t* const ctxtP,
                const rb_id_t         rb_idP,
                const mui_t           muiP,
                const rlc_tx_status_t statusP);)
197 198

typedef void (rrc_data_ind_cb_t)(
199 200 201
  const protocol_ctxt_t* const ctxtP,
  const rb_id_t     rb_idP,
  const sdu_size_t  sdu_sizeP,
202
  const uint8_t   * const sduP);
203 204

typedef void (rrc_data_conf_cb_t)(
205 206 207 208
  const protocol_ctxt_t* const ctxtP,
  const rb_id_t         rb_idP,
  const mui_t           muiP,
  const rlc_tx_status_t statusP);
209 210 211 212 213


/*! \struct  rlc_t
* \brief Structure to be instanciated to allocate memory for RLC protocol instances.
*/
214
typedef struct rlc_union_s {
215 216 217 218 219 220 221
  rlc_mode_t           mode;
  union {
    rlc_am_entity_t  am;
    rlc_um_entity_t  um;
    rlc_tm_entity_t  tm;
  } rlc;
} rlc_union_t;
222

223 224
typedef struct rlc_mbms_s {
  rb_id_t           rb_id;
225 226
  module_id_t       instanciated_instance;
  rlc_um_entity_t   um;
227 228
} rlc_mbms_t;

229 230 231 232 233
typedef struct rlc_mbms_id_s {
  mbms_service_id_t       service_id;
  mbms_session_id_t       session_id;
} rlc_mbms_id_t;

gauthier's avatar
gauthier committed
234 235
#if !defined(Rel10)
#    if !defined(maxServiceCount)
236
//unused arrays rlc_mbms_array_ue rlc_mbms_array_eNB
gauthier's avatar
gauthier committed
237 238 239
#        define maxServiceCount 1
#    endif
#    if !defined(maxSessionPerPMCH)
240
//unused arrays rlc_mbms_array_ue rlc_mbms_array_eNB
gauthier's avatar
gauthier committed
241 242 243
#        define maxSessionPerPMCH 1
#    endif
#endif
244 245
//public_rlc(rlc_mbms_t           rlc_mbms_array_ue[NUMBER_OF_UE_MAX][maxServiceCount][maxSessionPerPMCH];)   // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h
//public_rlc(rlc_mbms_t           rlc_mbms_array_eNB[NUMBER_OF_eNB_MAX][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h
246 247
public_rlc(rlc_mbms_id_t        rlc_mbms_lcid2service_session_id_ue[NUMBER_OF_UE_MAX][RLC_MAX_MBMS_LC];)    // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h
public_rlc(rlc_mbms_id_t        rlc_mbms_lcid2service_session_id_eNB[NUMBER_OF_eNB_MAX][RLC_MAX_MBMS_LC];)  // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h
248

gauthier's avatar
gauthier committed
249
#define rlc_mbms_enb_get_lcid_by_rb_id(Enb_mOD,rB_iD) rlc_mbms_rbid2lcid_eNB[Enb_mOD][rB_iD]
gauthier's avatar
gauthier committed
250
;
251 252

#define rlc_mbms_enb_set_lcid_by_rb_id(Enb_mOD,rB_iD,lOG_cH_iD) do { \
gauthier's avatar
gauthier committed
253
            rlc_mbms_rbid2lcid_eNB[Enb_mOD][rB_iD] = lOG_cH_iD; \
254 255
        } while (0);

gauthier's avatar
gauthier committed
256
#define rlc_mbms_ue_get_lcid_by_rb_id(uE_mOD,rB_iD) rlc_mbms_rbid2lcid_ue[uE_mOD][rB_iD]
257 258

#define rlc_mbms_ue_set_lcid_by_rb_id(uE_mOD,rB_iD,lOG_cH_iD) do { \
gauthier's avatar
gauthier committed
259 260
            AssertFatal(rB_iD<NB_RB_MAX, "INVALID RB ID %u", rB_iD); \
            rlc_mbms_rbid2lcid_ue[uE_mOD][rB_iD] = lOG_cH_iD; \
261 262 263 264 265 266
        } while (0);

public_rlc(logical_chan_id_t    rlc_mbms_rbid2lcid_ue [NUMBER_OF_UE_MAX][NB_RB_MBMS_MAX];)              /*!< \brief Pairing logical channel identifier with radio bearer identifer. */
public_rlc(logical_chan_id_t    rlc_mbms_rbid2lcid_eNB[NUMBER_OF_eNB_MAX][NB_RB_MBMS_MAX];)              /*!< \brief Pairing logical channel identifier with radio bearer identifer. */


267
#define RLC_COLL_KEY_VALUE(eNB_iD, rNTI, iS_eNB, rB_iD, iS_sRB) \
268
   ((hash_key_t)eNB_iD             | \
269 270 271 272
    (((hash_key_t)(rNTI))   << 8)  | \
    (((hash_key_t)(iS_eNB)) << 24) | \
    (((hash_key_t)(rB_iD))  << 25) | \
    (((hash_key_t)(iS_sRB)) << 33))
273 274 275

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

276
#define RLC_COLL_KEY_MBMS_VALUE(eNB_iD, rNTI, iS_eNB, sERVICE_ID, sESSION_ID) \
277
   ((hash_key_t)eNB_iD             | \
278 279 280 281
    (((hash_key_t)(rNTI))       << 8)  | \
    (((hash_key_t)(iS_eNB))     << 24) | \
    (((hash_key_t)(sERVICE_ID)) << 32) | \
    (((hash_key_t)(sESSION_ID)) << 37) | \
282 283 284 285
    (((hash_key_t)(0x0000000000000001))  << 63))

public_rlc(hash_table_t  *rlc_coll_p;)

286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
/*! \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.
*/
private_rlc_mac(tbs_size_t            mac_rlc_serialize_tb   (char*, list_t);)

/*! \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.
*/
private_rlc_mac(struct mac_data_ind   mac_rlc_deserialize_tb (char*, tb_size_t, num_tb_t, crc_t *);)


//-----------------------------------------------------------------------------
//   PUBLIC INTERFACE WITH RRC
//-----------------------------------------------------------------------------
#ifdef Rel10
309
/*! \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)
310
* \brief  Function for RRC to configure a Radio Bearer.
311
* \param[in]  ctxtP              Running context.
312 313 314 315 316 317
* \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.
*/
318
public_rlc_rrc( rlc_op_status_t rrc_rlc_config_asn1_req (
319 320 321 322 323
                  const protocol_ctxt_t* const,
                  const SRB_ToAddModList_t* const ,
                  const DRB_ToAddModList_t* const ,
                  const DRB_ToReleaseList_t* const ,
                  const PMCH_InfoList_r9_t * const pmch_info_listP);)
324
#else
325
/*! \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)
326
* \brief  Function for RRC to configure a Radio Bearer.
327
* \param[in]  ctxtP              Running context.
328 329 330 331 332
* \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.
*/
333
public_rlc_rrc( rlc_op_status_t rrc_rlc_config_asn1_req (
334 335 336 337
                  const protocol_ctxt_t* const,
                  const SRB_ToAddModList_t* const ,
                  const DRB_ToAddModList_t* const ,
                  const DRB_ToReleaseList_t* const );)
338 339
#endif

340 341 342 343 344 345 346

/*! \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.
 */
public_rlc_rrc(void
347
               rb_free_rlc_union (void *rlcu_pP);)
348 349


350
/*! \fn rlc_op_status_t rrc_rlc_remove_ue   (const protocol_ctxt_t* const ctxtP)
gauthier's avatar
gauthier committed
351
 * \brief  Remove all RLC protocol instances from all radio bearers allocated to a UE.
352
 * \param[in]  ctxtP              Running context.
gauthier's avatar
gauthier committed
353 354
 * \return     A status about the processing, OK or error code.
*/
355
public_rlc_rrc(rlc_op_status_t rrc_rlc_remove_ue (const protocol_ctxt_t* const);)
gauthier's avatar
gauthier committed
356 357


358
/*! \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)
359
* \brief  Remove a RLC protocol instance from a radio bearer.
360 361 362 363
* \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.
364 365
* \return     A status about the processing, OK or error code.
*/
366
public_rlc_rrc(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 );)
367

368
/*! \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)
369
* \brief  Add a RLC protocol instance to a radio bearer.
370 371 372 373 374 375
* \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).
376 377
* \return     A status about the processing, OK or error code.
*/
378
private_rlc_rrc(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);)
379 380

/*! \fn rlc_op_status_t rrc_rlc_config_req (
381
     const protocol_ctxt_t* const ctxtP,
382 383 384 385 386
     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)
387
* \brief  Function for RRC to configure a Radio Bearer.
388
* \param[in]  ctxtP            Running context.
389 390
* \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)
391 392 393 394 395
* \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.
*/
396
public_rlc_rrc( rlc_op_status_t rrc_rlc_config_req   (
397 398 399 400 401 402
                  const protocol_ctxt_t* const,
                  const srb_flag_t,
                  const MBMS_flag_t,
                  config_action_t,
                  const  rb_id_t,
                  rlc_info_t );)
403 404

/*! \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)
405
* \brief  Function for RRC to send a SDU through a Signalling Radio Bearer.
406
* \param[in]  ctxtP            Running context.
407 408 409 410 411 412 413 414
* \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.
*/
415
public_rlc_rrc( 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 *);)
416

417
/*! \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)
418 419 420 421
* \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.
*/
422
public_rlc_rrc(void rrc_rlc_register_rrc (rrc_data_ind_cb_t rrc_data_indP, rrc_data_conf_cb_t rrc_data_confP);)
423 424 425 426

//-----------------------------------------------------------------------------
//   PUBLIC INTERFACE WITH MAC
//-----------------------------------------------------------------------------
427
/*! \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)
428
* \brief    Interface with MAC layer, map data request to the RLC corresponding to the radio bearer.
429 430
* \param [in]     mod_idP          Virtualized module identifier.
* \param [in]     rntiP            UE identifier.
431 432
* \param [in]     frameP            Frame index
* \param [in]     eNB_flagP        Flag to indicate eNB (1) or UE (0)
433 434 435 436 437
* \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,out] bufferP          Memory area to fill with the bytes requested by MAC.
* \return     A status about the processing, OK or error code.
*/
438
public_rlc_mac(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, char*);)
439

440
/*! \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)
441
* \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.
442 443
* \param[in]  mod_idP          Virtualized module identifier.
* \param[in]  rntiP            UE identifier.
444
* \param[in]  frameP            Frame index
445 446 447 448 449 450 451 452
* \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.
*/
453
public_rlc_mac(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,
454
               crc_t* );)
455

456
/*! \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  eNB_flag_t eNB_flagP, const  MBMS_flag_t MBMS_flagP, logical_chan_id_t rb_idP, tb_size_t tb_sizeP)
457
* \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.
458 459
* \param[in]  mod_idP          Virtualized module identifier.
* \param[in]  rntiP            UE identifier.
460 461
* \param[in]  frameP            Frame index.
* \param[in]  eNB_flagP         Flag to indicate eNB operation (1 true, 0 false)
462 463 464 465 466
* \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.
*/
467
public_rlc_mac(mac_rlc_status_resp_t mac_rlc_status_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, tb_size_t );)
468 469 470 471 472 473 474 475 476 477
//-----------------------------------------------------------------------------
//   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
 */
478
public_rlc(void rlc_util_print_hex_octets(
479 480 481
             const comp_name_t componentP,
             unsigned char* const dataP,
             const signed long sizeP);)
482 483 484



485
/*! \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)
486
* \brief    Interface with higher layers, map request to the RLC corresponding to the radio bearer.
487
* \param[in]  ctxtP            Running context.
488
* \param[in]  srb_flagP        Flag to indicate SRB (1) or DRB (0)
489 490 491 492 493 494 495 496
* \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.
*/
497
public_rlc(rlc_op_status_t rlc_data_req     (
498 499 500 501 502 503 504 505
             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 ,
             mem_block_t * const);)
506 507

/*! \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) {
508
* \brief    Interface with higher layers, route SDUs coming from RLC protocol instances to upper layer instance.
509
* \param[in]  ctxtP            Running context.
510
* \param[in]  srb_flagP        Flag to indicate SRB (1) or DRB (0)
511 512 513 514 515
* \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.
*/
516
public_rlc(void rlc_data_ind(
517 518 519 520 521 522
             const protocol_ctxt_t* const,
             const srb_flag_t,
             const MBMS_flag_t ,
             const rb_id_t,
             const sdu_size_t,
             mem_block_t* const);)
523 524 525


/*! \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)
526
* \brief    Interface with higher layers, confirm to upper layer the transmission status for a SDU stamped with a MUI, scheduled for transmission.
527
* \param[in]  ctxtP            Running context.
528
* \param[in]  srb_flagP        Flag to indicate SRB (1) or DRB (0)
529 530 531 532
* \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).
*/
533
public_rlc(void rlc_data_conf(
534 535 536 537 538
             const protocol_ctxt_t* const,
             const  srb_flag_t,
             const  rb_id_t,
             const mui_t,
             const rlc_tx_status_t );)
539 540


541
/*! \fn rlc_op_status_t rlc_stat_req     (
542
                        const protocol_ctxt_t* const ctxtP,
543 544
                        const  srb_flag_t    srb_flagP,
                        const  rb_id_t       rb_idP,
545 546
                        unsigned int* stat_rlc_mode,
			unsigned int* stat_tx_pdcp_sdu,
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
                        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.
575
* \param[in]  ctxtP                Running context.
576
* \param[in]  srb_flagP            Flag to indicate signalling radio bearer (1) or data radio bearer (0).
577
* \param[in]  rb_idP                       .
578
* \param[out] stat_rlc_mode                        RLC mode 
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607
* \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.
*/

608
public_rlc(rlc_op_status_t rlc_stat_req     (
609 610 611
             const protocol_ctxt_t* const ctxtP,
             const srb_flag_t    srb_flagP,
             const rb_id_t       rb_idP,
612 613
             unsigned int* const stat_rlc_mode,
	     unsigned int* const stat_tx_pdcp_sdu,
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639
             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,
             unsigned int* const stat_timer_status_prohibit_timed_out);)
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673

/*! \fn int rlc_module_init(void)
* \brief    RAZ the memory of the RLC layer, initialize the memory pool manager (mem_block_t structures mainly used in RLC module).
*/
public_rlc(int rlc_module_init(void);)

/** @} */
#ifndef USER_MODE
#define assert(x) ((x)?msg("rlc assertion fails\n"):0)
#endif


#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