rlc.c 41.3 KB
Newer Older
1 2
/*******************************************************************************
Eurecom OpenAirInterface 2
gauthier's avatar
Licence  
gauthier committed
3
Copyright(c) 1999 - 2014 Eurecom
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.

This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.

The full GNU General Public License is included in this distribution in
the file called "COPYING".

Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums       : http://forums.eurecom.fsr/openairinterface
gauthier's avatar
Licence  
gauthier committed
25 26 27 28 29 30
Address      : EURECOM,
               Campus SophiaTech,
               450 Route des Chappes,
               CS 50193
               06904 Biot Sophia Antipolis cedex,
               FRANCE
31
*******************************************************************************/
gauthier's avatar
Licence  
gauthier committed
32 33 34 35 36 37 38
/*
                                rlc.c
                             -------------------
  AUTHOR  : Lionel GAUTHIER
  COMPANY : EURECOM
  EMAIL   : Lionel.Gauthier at eurecom dot fr
*/
39 40 41 42 43
#define RLC_C
#include "rlc.h"
#include "mem_block.h"
#include "../MAC/extern.h"
#include "UTIL/LOG/log.h"
gauthier's avatar
gauthier committed
44
#include "UTIL/OCG/OCG_vars.h"
45 46 47

#include "assertions.h"

gauthier's avatar
gauthier committed
48
extern void pdcp_data_ind (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t enb_flagP, MBMS_flag_t MBMS_flag, rb_id_t rab_idP, sdu_size_t data_sizeP, mem_block_t * sdu_pP, uint8_t is_data_plane);
49

gauthier's avatar
gauthier committed
50
#define DEBUG_RLC_PDCP_INTERFACE
51

gauthier's avatar
gauthier committed
52
#define DEBUG_RLC_DATA_REQ 1
53 54 55 56 57 58 59 60 61 62 63 64

//-----------------------------------------------------------------------------
void rlc_util_print_hex_octets(comp_name_t componentP, unsigned char* dataP, unsigned long sizeP)
//-----------------------------------------------------------------------------
{
  unsigned long octet_index = 0;

  if (dataP == NULL) {
    return;
  }


65 66 67 68 69


  LOG_T(componentP, "+-----+-------------------------------------------------+\n");
  LOG_T(componentP, "|     |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |\n");
  LOG_T(componentP, "+-----+-------------------------------------------------+\n");
70 71 72
  for (octet_index = 0; octet_index < sizeP; octet_index++) {
    if ((octet_index % 16) == 0){
      if (octet_index != 0) {
73
        LOG_T(componentP, " |\n");
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
      }
      LOG_T(componentP, " %04d |", octet_index);
    }
    /*
     * Print every single octet in hexadecimal form
     */
    LOG_T(componentP, " %02x", dataP[octet_index]);
    /*
     * Align newline and pipes according to the octets in groups of 2
     */
  }

  /*
   * Append enough spaces and put final pipe
   */
  unsigned char index;
  for (index = octet_index; index < 16; ++index)
    LOG_T(componentP, "   ");
  LOG_T(componentP, " |\n");
}

//-----------------------------------------------------------------------------
gauthier's avatar
gauthier committed
96 97 98 99
rlc_op_status_t rlc_stat_req     (
                  module_id_t   enb_mod_idP,
                  module_id_t   ue_mod_idP,
                  frame_t       frameP,
gauthier's avatar
gauthier committed
100
                  eNB_flag_t    enb_flagP,
gauthier's avatar
gauthier committed
101
                  rb_id_t       rb_idP,
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
                  unsigned int* stat_tx_pdcp_sdu,
                  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) {
//-----------------------------------------------------------------------------
gauthier's avatar
gauthier committed
130
    rlc_mode_t             rlc_mode = RLC_MODE_NONE;
131
    void                  *rlc_p      = NULL;
gauthier's avatar
gauthier committed
132 133

#ifdef OAI_EMU
gauthier's avatar
gauthier committed
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
    if (enb_flagP) {
        AssertFatal ((enb_mod_idP >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0),
            "eNB module id is too low (%u/%d)!\n",
            enb_mod_idP,
            oai_emulation.info.first_enb_local);
        AssertFatal ((enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0),
            "eNB module id is too high (%u/%d)!\n",
            enb_mod_idP,
            oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local);
        AssertFatal (ue_mod_idP  < NB_UE_INST,
            "UE module id is too high (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);
    } else {
        AssertFatal (ue_mod_idP  < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local),
            "UE module id is too high (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);
        AssertFatal (ue_mod_idP  >= oai_emulation.info.first_ue_local,
            "UE module id is too low (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local);
    }
gauthier's avatar
gauthier committed
157 158
#endif
    AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX);
gauthier's avatar
gauthier committed
159
    if (enb_flagP) {
gauthier's avatar
gauthier committed
160 161
        rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode;
        switch (rlc_mode) {
gauthier's avatar
gauthier committed
162
          case RLC_MODE_NONE:
gauthier's avatar
gauthier committed
163 164
              AssertFatal (0 , "enB RLC not configured rb id %u  module eNB id %u!\n", rb_idP, enb_mod_idP);
              break;
gauthier's avatar
gauthier committed
165
          case RLC_MODE_AM:
166
              rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.am;
gauthier's avatar
gauthier committed
167
              break;
gauthier's avatar
gauthier committed
168
          case RLC_MODE_UM:
169
              rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.um;
gauthier's avatar
gauthier committed
170
              break;
gauthier's avatar
gauthier committed
171
          case RLC_MODE_TM:
172
              rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.tm;
gauthier's avatar
gauthier committed
173 174 175 176 177 178 179
              break;
          default:
              AssertFatal (0 , "enB RLC internal memory error rb id %u module eNB id %u!\n", rb_idP, enb_mod_idP);
        }
    } else {
        rlc_mode = rlc_array_ue[ue_mod_idP][rb_idP].mode;
        switch (rlc_mode) {
gauthier's avatar
gauthier committed
180
          case RLC_MODE_NONE:
gauthier's avatar
gauthier committed
181 182
              AssertFatal (0 , "UE RLC not configured rb id %u module ue id %u!\n", rb_idP, ue_mod_idP);
              break;
gauthier's avatar
gauthier committed
183
          case RLC_MODE_AM:
184
              rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_idP].rlc.am;
gauthier's avatar
gauthier committed
185
              break;
gauthier's avatar
gauthier committed
186
          case RLC_MODE_UM:
187
              rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_idP].rlc.um;
gauthier's avatar
gauthier committed
188
              break;
gauthier's avatar
gauthier committed
189
          case RLC_MODE_TM:
190
              rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_idP].rlc.tm;
gauthier's avatar
gauthier committed
191 192 193 194 195 196
              break;
          default:
              AssertFatal (0 , "UE RLC internal memory error rb id %u module ue id %u!\n", rb_idP, ue_mod_idP);
        }
    }
    switch (rlc_mode) {
gauthier's avatar
gauthier committed
197
        case RLC_MODE_NONE:
gauthier's avatar
gauthier committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
            *stat_tx_pdcp_sdu                     = 0;
            *stat_tx_pdcp_bytes                   = 0;
            *stat_tx_pdcp_sdu_discarded           = 0;
            *stat_tx_pdcp_bytes_discarded         = 0;
            *stat_tx_data_pdu                     = 0;
            *stat_tx_data_bytes                   = 0;
            *stat_tx_retransmit_pdu_by_status     = 0;
            *stat_tx_retransmit_bytes_by_status   = 0;
            *stat_tx_retransmit_pdu               = 0;
            *stat_tx_retransmit_bytes             = 0;
            *stat_tx_control_pdu                  = 0;
            *stat_tx_control_bytes                = 0;
            *stat_rx_pdcp_sdu                     = 0;
            *stat_rx_pdcp_bytes                   = 0;
            *stat_rx_data_pdus_duplicate          = 0;
            *stat_rx_data_bytes_duplicate         = 0;
            *stat_rx_data_pdu                     = 0;
            *stat_rx_data_bytes                   = 0;
            *stat_rx_data_pdu_dropped             = 0;
            *stat_rx_data_bytes_dropped           = 0;
            *stat_rx_data_pdu_out_of_window       = 0;
            *stat_rx_data_bytes_out_of_window     = 0;
            *stat_rx_control_pdu                  = 0;
            *stat_rx_control_bytes                = 0;
            *stat_timer_reordering_timed_out      = 0;
            *stat_timer_poll_retransmit_timed_out = 0;
            *stat_timer_status_prohibit_timed_out = 0;
            return RLC_OP_STATUS_BAD_PARAMETER;
            break;

gauthier's avatar
gauthier committed
228
        case RLC_MODE_AM:
229
            rlc_am_stat_req((rlc_am_entity_t*)rlc_p,
gauthier's avatar
gauthier committed
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
                            stat_tx_pdcp_sdu,
                            stat_tx_pdcp_bytes,
                            stat_tx_pdcp_sdu_discarded,
                            stat_tx_pdcp_bytes_discarded,
                            stat_tx_data_pdu,
                            stat_tx_data_bytes,
                            stat_tx_retransmit_pdu_by_status,
                            stat_tx_retransmit_bytes_by_status,
                            stat_tx_retransmit_pdu,
                            stat_tx_retransmit_bytes,
                            stat_tx_control_pdu,
                            stat_tx_control_bytes,
                            stat_rx_pdcp_sdu,
                            stat_rx_pdcp_bytes,
                            stat_rx_data_pdus_duplicate,
                            stat_rx_data_bytes_duplicate,
                            stat_rx_data_pdu,
                            stat_rx_data_bytes,
                            stat_rx_data_pdu_dropped,
                            stat_rx_data_bytes_dropped,
                            stat_rx_data_pdu_out_of_window,
                            stat_rx_data_bytes_out_of_window,
                            stat_rx_control_pdu,
                            stat_rx_control_bytes,
                            stat_timer_reordering_timed_out,
                            stat_timer_poll_retransmit_timed_out,
                            stat_timer_status_prohibit_timed_out);
                            return RLC_OP_STATUS_OK;
           break;

gauthier's avatar
gauthier committed
260
       case RLC_MODE_UM:
gauthier's avatar
gauthier committed
261 262 263 264 265 266 267 268 269 270 271 272
           *stat_tx_retransmit_pdu_by_status     = 0;
           *stat_tx_retransmit_bytes_by_status   = 0;
           *stat_tx_retransmit_pdu               = 0;
           *stat_tx_retransmit_bytes             = 0;
           *stat_tx_control_pdu                  = 0;
           *stat_tx_control_bytes                = 0;
           *stat_rx_data_pdu_dropped             = 0;
           *stat_rx_data_bytes_dropped           = 0;
           *stat_rx_data_pdu_out_of_window       = 0;
           *stat_rx_data_bytes_out_of_window     = 0;
           *stat_timer_poll_retransmit_timed_out = 0;
           *stat_timer_status_prohibit_timed_out = 0;
273
           rlc_um_stat_req ((rlc_um_entity_t*)rlc_p,
gauthier's avatar
gauthier committed
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
                              stat_tx_pdcp_sdu,
                              stat_tx_pdcp_bytes,
                              stat_tx_pdcp_sdu_discarded,
                              stat_tx_pdcp_bytes_discarded,
                              stat_tx_data_pdu,
                              stat_tx_data_bytes,
                              stat_rx_pdcp_sdu,
                              stat_rx_pdcp_bytes,
                              stat_rx_data_pdus_duplicate,
                              stat_rx_data_bytes_duplicate,
                              stat_rx_data_pdu,
                              stat_rx_data_bytes,
                              stat_rx_data_pdu_dropped,
                              stat_rx_data_bytes_dropped,
                              stat_rx_data_pdu_out_of_window,
                              stat_rx_data_bytes_out_of_window,
                              stat_timer_reordering_timed_out);
           return RLC_OP_STATUS_OK;
           break;

gauthier's avatar
gauthier committed
294
       case RLC_MODE_TM:
gauthier's avatar
gauthier committed
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
           *stat_tx_pdcp_sdu                     = 0;
           *stat_tx_pdcp_bytes                   = 0;
           *stat_tx_pdcp_sdu_discarded           = 0;
           *stat_tx_pdcp_bytes_discarded         = 0;
           *stat_tx_data_pdu                     = 0;
           *stat_tx_data_bytes                   = 0;
           *stat_tx_retransmit_pdu_by_status     = 0;
           *stat_tx_retransmit_bytes_by_status   = 0;
           *stat_tx_retransmit_pdu               = 0;
           *stat_tx_retransmit_bytes             = 0;
           *stat_tx_control_pdu                  = 0;
           *stat_tx_control_bytes                = 0;
           *stat_rx_pdcp_sdu                     = 0;
           *stat_rx_pdcp_bytes                   = 0;
           *stat_rx_data_pdus_duplicate          = 0;
           *stat_rx_data_bytes_duplicate         = 0;
           *stat_rx_data_pdu                     = 0;
           *stat_rx_data_bytes                   = 0;
           *stat_rx_data_pdu_dropped             = 0;
           *stat_rx_data_bytes_dropped           = 0;
           *stat_rx_data_pdu_out_of_window       = 0;
           *stat_rx_data_bytes_out_of_window     = 0;
           *stat_rx_control_pdu                  = 0;
           *stat_rx_control_bytes                = 0;
           *stat_timer_reordering_timed_out      = 0;
           *stat_timer_poll_retransmit_timed_out = 0;
           *stat_timer_status_prohibit_timed_out = 0;
           return RLC_OP_STATUS_BAD_PARAMETER;
           break;

       default:
           *stat_tx_pdcp_sdu                     = 0;
           *stat_tx_pdcp_bytes                   = 0;
           *stat_tx_pdcp_sdu_discarded           = 0;
           *stat_tx_pdcp_bytes_discarded         = 0;
           *stat_tx_data_pdu                     = 0;
           *stat_tx_data_bytes                   = 0;
           *stat_tx_retransmit_pdu_by_status     = 0;
           *stat_tx_retransmit_bytes_by_status   = 0;
           *stat_tx_retransmit_pdu               = 0;
           *stat_tx_retransmit_bytes             = 0;
           *stat_tx_control_pdu                  = 0;
           *stat_tx_control_bytes                = 0;
           *stat_rx_pdcp_sdu                     = 0;
           *stat_rx_pdcp_bytes                   = 0;
           *stat_rx_data_pdus_duplicate          = 0;
           *stat_rx_data_bytes_duplicate         = 0;
           *stat_rx_data_pdu                     = 0;
           *stat_rx_data_bytes                   = 0;
           *stat_rx_data_pdu_dropped             = 0;
           *stat_rx_data_bytes_dropped           = 0;
           *stat_rx_data_pdu_out_of_window       = 0;
           *stat_rx_data_bytes_out_of_window     = 0;
           *stat_rx_control_pdu                  = 0;
           *stat_rx_control_bytes                = 0;

           *stat_timer_poll_retransmit_timed_out = 0;
           *stat_timer_status_prohibit_timed_out = 0;
           return RLC_OP_STATUS_BAD_PARAMETER;
    }
355 356
}
//-----------------------------------------------------------------------------
357 358 359
rlc_op_status_t rlc_data_req     (module_id_t  enb_mod_idP,
                                  module_id_t  ue_mod_idP,
                                  frame_t      frameP,
gauthier's avatar
gauthier committed
360
                                  eNB_flag_t   enb_flagP,
361 362 363 364 365
                                  MBMS_flag_t  MBMS_flagP,
                                  rb_id_t      rb_idP,
                                  mui_t        muiP,
                                  confirm_t    confirmP,
                                  sdu_size_t   sdu_sizeP,
gauthier's avatar
gauthier committed
366
                                  mem_block_t *sdu_pP) {
367
//-----------------------------------------------------------------------------
368
  mem_block_t           *new_sdu_p    = NULL;
gauthier's avatar
gauthier committed
369
  rlc_mode_t             rlc_mode     = RLC_MODE_NONE;
370
  void                  *rlc_p        = NULL;
371
#ifdef Rel10
gauthier's avatar
gauthier committed
372
  rb_id_t                mbms_rb_id = 0;
373
  rlc_um_entity_t       *rlc_um_p   = NULL;
374 375
  rlc_mbms_id_t         *mbms_id_p  = NULL;
  logical_chan_id_t      log_ch_id  = 0;
376 377
#endif
#ifdef DEBUG_RLC_DATA_REQ
gauthier's avatar
gauthier committed
378
  LOG_D(RLC,"rlc_data_req: %s enb id  %u  ue id %u, rb_id %u (MAX %d), muip %d, confirmP %d, sud_sizeP %d, sdu_pP %p\n",
gauthier's avatar
gauthier committed
379
        (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
380 381 382 383 384 385 386 387
        enb_mod_idP,
        ue_mod_idP,
        rb_idP,
        NB_RAB_MAX,
        muiP,
        confirmP,
        sdu_sizeP,
        sdu_pP);
388
#endif
389 390
#ifdef Rel10
#else
gauthier's avatar
gauthier committed
391
  AssertFatal(MBMS_flagP == 0, "MBMS_flagP %u", MBMS_flagP);
392
#endif
gauthier's avatar
gauthier committed
393
#ifdef OAI_EMU
gauthier's avatar
gauthier committed
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
  if (enb_flagP) {
      AssertFatal ((enb_mod_idP >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0),
          "eNB module id is too low (%u/%d)!\n",
          enb_mod_idP,
          oai_emulation.info.first_enb_local);
      AssertFatal ((enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0),
          "eNB module id is too high (%u/%d)!\n",
          enb_mod_idP,
          oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local);
      AssertFatal (ue_mod_idP  < NB_UE_INST,
          "UE module id is too high (%u/%d)!\n",
          ue_mod_idP,
          oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);
  } else {
      AssertFatal (ue_mod_idP  < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local),
          "UE module id is too high (%u/%d)!\n",
          ue_mod_idP,
          oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);
      AssertFatal (ue_mod_idP  >= oai_emulation.info.first_ue_local,
          "UE module id is too low (%u/%d)!\n",
          ue_mod_idP,
          oai_emulation.info.first_ue_local);
  }
gauthier's avatar
gauthier committed
417
#endif
418 419 420 421 422
  if (MBMS_flagP) {
      AssertFatal (rb_idP < NB_RB_MBMS_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MBMS_MAX);
  } else {
      AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX);
  }
gauthier's avatar
gauthier committed
423
  DevAssert(sdu_pP != NULL);
424 425 426 427 428 429
  DevCheck(sdu_sizeP > 0, sdu_sizeP, 0, 0);

#ifndef Rel10
  DevCheck(MBMS_flagP == 0, MBMS_flagP, 0, 0);
#endif

430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
#ifdef Rel10
  if (MBMS_flagP == TRUE) {
      if (enb_flagP) {
            log_ch_id = rlc_mbms_enb_get_lcid_by_rb_id(enb_mod_idP,rb_idP);
            mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[enb_mod_idP][log_ch_id];
            rlc_um_p  = &rlc_mbms_array_eNB[enb_mod_idP][mbms_id_p->service_id][mbms_id_p->session_id].um;
            LOG_D(RLC,"eNB rlc_um_p : %p RB %u service %u session %u\n",
                  rlc_um_p,
                  rb_idP,
                  mbms_id_p->service_id,
                  mbms_id_p->session_id
                 );

      } else {
            log_ch_id = rlc_mbms_ue_get_lcid_by_rb_id(ue_mod_idP,rb_idP);
            mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[ue_mod_idP][log_ch_id];
            rlc_um_p  = &rlc_mbms_array_ue[ue_mod_idP][mbms_id_p->service_id][mbms_id_p->session_id].um;
            LOG_D(RLC,"UE rlc_um_p : %p RB %u service %u session %u\n",
                  rlc_um_p,
                  rb_idP,
                  mbms_id_p->service_id,
                  mbms_id_p->session_id
                 );
gauthier's avatar
gauthier committed
453
      }
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
  } else
#endif
  {
      if (enb_flagP) {
          rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode;
          switch (rlc_mode) {
            case RLC_MODE_NONE:
                AssertFatal (0 , "enB RLC not configured rb id %u module %u!\n", rb_idP, enb_mod_idP);
                break;
            case RLC_MODE_AM:
                rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.am;
                break;
            case RLC_MODE_UM:
                rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.um;
                break;
            case RLC_MODE_TM:
                rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.tm;
                break;
            default:
                AssertFatal (0 , "enB RLC internal memory error rb id %u module %u!\n", rb_idP, enb_mod_idP);
          }
      } else {
          rlc_mode = rlc_array_ue[ue_mod_idP][rb_idP].mode;
          switch (rlc_mode) {
            case RLC_MODE_NONE:
                AssertFatal (0 , "UE RLC not configured rb id %u module %u!\n", rb_idP, ue_mod_idP);
                break;
            case RLC_MODE_AM:
                rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_idP].rlc.am;
                break;
            case RLC_MODE_UM:
                rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_idP].rlc.um;
                break;
            case RLC_MODE_TM:
                rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_idP].rlc.tm;
                break;
            default:
                AssertFatal (0 , "UE RLC internal memory error rb id %u module %u!\n", rb_idP, ue_mod_idP);
          }
gauthier's avatar
gauthier committed
493 494 495
      }
  }

496
  if (MBMS_flagP == 0) {
gauthier's avatar
gauthier committed
497
      LOG_D(RLC, "[FRAME %5u][%s][RLC][INST %u/%u][RB %u] Display of rlc_data_req:\n",
498
          frameP,
gauthier's avatar
gauthier committed
499
          (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
500 501 502 503
          enb_mod_idP,
          ue_mod_idP,
          rb_idP);
      rlc_util_print_hex_octets(RLC, (unsigned char*)sdu_pP->data, sdu_sizeP);
504 505

#ifdef DEBUG_RLC_DATA_REQ
gauthier's avatar
gauthier committed
506
      LOG_D(RLC,"RLC_TYPE : %d ",rlc_mode);
507
#endif
gauthier's avatar
gauthier committed
508
      switch (rlc_mode) {
gauthier's avatar
gauthier committed
509
          case RLC_MODE_NONE:
gauthier's avatar
gauthier committed
510
              free_mem_block(sdu_pP);
gauthier's avatar
gauthier committed
511
              LOG_E(RLC, "Received RLC_MODE_NONE as rlc_type for %s eNB id  %u, ue id %u, rb_id %u\n",
gauthier's avatar
gauthier committed
512
                    (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
513 514 515 516
                    enb_mod_idP,
                    ue_mod_idP,
                    rb_idP);
              return RLC_OP_STATUS_BAD_PARAMETER;
517

gauthier's avatar
gauthier committed
518
          case RLC_MODE_AM:
519
#ifdef DEBUG_RLC_DATA_REQ
gauthier's avatar
gauthier committed
520
              msg("RLC_MODE_AM\n");
521
#endif
522
              new_sdu_p = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_am_data_req_alloc));
gauthier's avatar
gauthier committed
523

524
              if (new_sdu_p != NULL) {
gauthier's avatar
gauthier committed
525
                  // PROCESS OF COMPRESSION HERE:
526 527
                  memset (new_sdu_p->data, 0, sizeof (struct rlc_am_data_req_alloc));
                  memcpy (&new_sdu_p->data[sizeof (struct rlc_am_data_req_alloc)], &sdu_pP->data[0], sdu_sizeP);
gauthier's avatar
gauthier committed
528

529 530 531 532
                  ((struct rlc_am_data_req *) (new_sdu_p->data))->data_size = sdu_sizeP;
                  ((struct rlc_am_data_req *) (new_sdu_p->data))->conf = confirmP;
                  ((struct rlc_am_data_req *) (new_sdu_p->data))->mui  = muiP;
                  ((struct rlc_am_data_req *) (new_sdu_p->data))->data_offset = sizeof (struct rlc_am_data_req_alloc);
gauthier's avatar
gauthier committed
533 534 535
                  free_mem_block(sdu_pP);
                  LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED);

536
                  if (((rlc_am_entity_t*)rlc_p)->is_data_plane) {
gauthier's avatar
gauthier committed
537
                      LOG_D(RLC, "[FRAME %5u][%s][PDCP][INST %u/%u][RB %u][--- RLC_AM_DATA_REQ/%d Bytes --->][RLC_AM][INST %u/%u][RB %u]\n",
538
                          frameP,
gauthier's avatar
gauthier committed
539
                          (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
540 541 542 543 544 545 546 547 548
                          enb_mod_idP,
                          ue_mod_idP,
                          rb_idP,
                          sdu_sizeP,
                          ue_mod_idP,
                          rb_idP,
                          rb_idP);
                  } else {
                      LOG_D(RLC, "[FRAME %5u][%s][RRC][INST %u/%u][][--- RLC_AM_DATA_REQ/%d Bytes --->][RLC_AM][INST %u/%u][RB %u]\n",
549
                          frameP,
gauthier's avatar
gauthier committed
550
                          (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
551 552 553 554 555 556 557 558 559
                          enb_mod_idP,
                          ue_mod_idP,
                          rb_idP,
                          sdu_sizeP,
                          enb_mod_idP,
                          ue_mod_idP,
                          rb_idP);
                  }
                  LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT);
560
                  rlc_am_data_req((rlc_am_entity_t*)rlc_p, frameP, new_sdu_p);
gauthier's avatar
gauthier committed
561 562 563 564 565 566
                  return RLC_OP_STATUS_OK;
              } else {
                  return RLC_OP_STATUS_INTERNAL_ERROR;
              }
              break;

gauthier's avatar
gauthier committed
567
          case RLC_MODE_UM:
568
            new_sdu_p = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_um_data_req_alloc));
gauthier's avatar
gauthier committed
569

570
              if (new_sdu_p != NULL) {
gauthier's avatar
gauthier committed
571
                  // PROCESS OF COMPRESSION HERE:
572 573
                  memset (new_sdu_p->data, 0, sizeof (struct rlc_um_data_req_alloc));
                  memcpy (&new_sdu_p->data[sizeof (struct rlc_um_data_req_alloc)], &sdu_pP->data[0], sdu_sizeP);
gauthier's avatar
gauthier committed
574

575 576
                  ((struct rlc_um_data_req *) (new_sdu_p->data))->data_size = sdu_sizeP;
                  ((struct rlc_um_data_req *) (new_sdu_p->data))->data_offset = sizeof (struct rlc_um_data_req_alloc);
gauthier's avatar
gauthier committed
577 578 579
                  free_mem_block(sdu_pP);

                  LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED);
580
                  if (((rlc_am_entity_t*)rlc_p)->is_data_plane) {
gauthier's avatar
gauthier committed
581
                      LOG_D(RLC, "[FRAME %5u][%s][PDCP][INST %u/%u][RB %u][--- RLC_UM_DATA_REQ/%d Bytes --->][RLC_UM][INST %u/%u][RB %u]\n",
582
                          frameP,
gauthier's avatar
gauthier committed
583
                          (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
584 585 586 587 588 589 590 591 592
                          enb_mod_idP,
                          ue_mod_idP,
                          rb_idP,
                          sdu_sizeP,
                          enb_mod_idP,
                          ue_mod_idP,
                          rb_idP);
                  } else {
                      LOG_D(RLC, "[FRAME %5u][%s][RRC][INST %u/%u][][--- RLC_UM_DATA_REQ/%d Bytes --->][RLC_UM][INST %u/%u][RB %u]\n",
593
                                     frameP,
gauthier's avatar
gauthier committed
594
                                     (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
595 596 597 598 599 600 601 602 603
                                     enb_mod_idP,
                                     ue_mod_idP,
                                     rb_idP,
                                     sdu_sizeP,
                                     enb_mod_idP,
                                     ue_mod_idP,
                                     rb_idP);
                  }
                  LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT);
604
                  rlc_um_data_req((rlc_um_entity_t*)rlc_p, frameP, new_sdu_p);
605

gauthier's avatar
gauthier committed
606 607 608 609 610 611 612
                  //free_mem_block(new_sdu);
                  return RLC_OP_STATUS_OK;
              } else {
                  return RLC_OP_STATUS_INTERNAL_ERROR;
              }
              break;

gauthier's avatar
gauthier committed
613
          case RLC_MODE_TM:
614
            new_sdu_p = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_tm_data_req_alloc));
gauthier's avatar
gauthier committed
615

616
              if (new_sdu_p != NULL) {
gauthier's avatar
gauthier committed
617
                  // PROCESS OF COMPRESSION HERE:
618 619
                  memset (new_sdu_p->data, 0, sizeof (struct rlc_tm_data_req_alloc));
                  memcpy (&new_sdu_p->data[sizeof (struct rlc_tm_data_req_alloc)], &sdu_pP->data[0], sdu_sizeP);
gauthier's avatar
gauthier committed
620

621 622
                  ((struct rlc_tm_data_req *) (new_sdu_p->data))->data_size = sdu_sizeP;
                  ((struct rlc_tm_data_req *) (new_sdu_p->data))->data_offset = sizeof (struct rlc_tm_data_req_alloc);
gauthier's avatar
gauthier committed
623 624
                  free_mem_block(sdu_pP);
                  LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED);
625
                  if (((rlc_tm_entity_t*)rlc_p)->is_data_plane) {
gauthier's avatar
gauthier committed
626
                      LOG_D(RLC, "[FRAME %5u][%s][PDCP][INST %u/%u][RB %u][--- RLC_TM_DATA_REQ/%d Bytes --->][RLC_TM][INST %u/%u][RB %u]\n",
627
                                 frameP,
gauthier's avatar
gauthier committed
628
                                 (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
629 630 631 632 633 634 635 636 637
                                 enb_mod_idP,
                                 ue_mod_idP,
                                 rb_idP,
                                 sdu_sizeP,
                                 enb_mod_idP,
                                 ue_mod_idP,
                                 rb_idP);
                  } else {
                       LOG_D(RLC, "[FRAME %5u][%s][RRC][INST %u/%u][][--- RLC_TM_DATA_REQ/%d Bytes --->][RLC_TM][INST %u/%u][RB %u]\n",
638
                                     frameP,
gauthier's avatar
gauthier committed
639
                                     (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
640 641 642 643 644 645 646
                                     enb_mod_idP,
                                     ue_mod_idP,
                                     rb_idP,
                                     sdu_sizeP,
                                     enb_mod_idP,
                                     ue_mod_idP,
                                     rb_idP);
647
                  }
gauthier's avatar
gauthier committed
648
                  LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT);
649
                  rlc_tm_data_req((rlc_tm_entity_t*)rlc_p, new_sdu_p);
gauthier's avatar
gauthier committed
650 651 652 653 654 655 656 657 658 659 660 661
                  return RLC_OP_STATUS_OK;
              } else {
                  //handle_event(ERROR,"FILE %s FONCTION rlc_data_req() LINE %s : out of memory\n", __FILE__, __LINE__);
                  return RLC_OP_STATUS_INTERNAL_ERROR;
              }
              break;

          default:
              free_mem_block(sdu_pP);
              return RLC_OP_STATUS_INTERNAL_ERROR;

      }
662

663
#ifdef Rel10
664
  } else { /* MBMS_flag != 0 */
665
	  //  LOG_I(RLC,"DUY rlc_data_req: mbms_rb_id in RLC instant is: %d\n", mbms_rb_id);
gauthier's avatar
gauthier committed
666
          if (sdu_pP != NULL) {
667 668
              if (sdu_sizeP > 0) {
                  LOG_I(RLC,"received a packet with size %d for MBMS \n", sdu_sizeP);
669 670
                  new_sdu_p = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_um_data_req_alloc));
                  if (new_sdu_p != NULL) {
671
                      // PROCESS OF COMPRESSION HERE:
672 673 674 675
                      memset (new_sdu_p->data, 0, sizeof (struct rlc_um_data_req_alloc));
                      memcpy (&new_sdu_p->data[sizeof (struct rlc_um_data_req_alloc)], &sdu_pP->data[0], sdu_sizeP);
                      ((struct rlc_um_data_req *) (new_sdu_p->data))->data_size = sdu_sizeP;
                      ((struct rlc_um_data_req *) (new_sdu_p->data))->data_offset = sizeof (struct rlc_um_data_req_alloc);
gauthier's avatar
gauthier committed
676
                      free_mem_block(sdu_pP);
677
                      LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED);
678
                      if (rlc_um_p->is_data_plane) {
gauthier's avatar
gauthier committed
679
                          LOG_D(RLC, "[FRAME %5u][PDCP][INST %u/%u][RB %u][--- RLC_UM_DATA_REQ/%d Bytes (MBMS) --->][RLC_UM][INST %u/%u][RB %u]\n",
680
                            frameP,
gauthier's avatar
gauthier committed
681 682 683 684 685 686
                            enb_mod_idP,
                            ue_mod_idP,
                            rb_idP,
                            sdu_sizeP,
                            enb_mod_idP,
                            ue_mod_idP,
687
                            rb_idP);
688
                      } else {
gauthier's avatar
gauthier committed
689
                          if (enb_flagP) {
690
                              LOG_D(RLC, "[FRAME %5u][RRC_eNB][INST %u/%u][%u][--- RLC_UM_DATA_REQ/%d Bytes (MBMS) --->][RLC_UM][INST %u/%u][RB %u]\n",
691
                                 frameP,
gauthier's avatar
gauthier committed
692 693 694 695 696 697
                                 enb_mod_idP,
                                 ue_mod_idP,
                                 rb_idP,
                                 sdu_sizeP,
                                 enb_mod_idP,
                                 ue_mod_idP,
698
                                 rb_idP);
699
                          } else {
700
                              LOG_D(RLC, "[FRAME %5u][RRC_UE][INST %u/%u][%u][--- RLC_UM_DATA_REQ/%d Bytes (MBMS) --->][RLC_UM][INST %u/%u][RB %u]\n",
701
                                 frameP,
gauthier's avatar
gauthier committed
702 703 704 705 706 707
                                 enb_mod_idP,
                                 ue_mod_idP,
                                 rb_idP,
                                 sdu_sizeP,
                                 enb_mod_idP,
                                 ue_mod_idP,
708
                                 rb_idP);
709 710 711
                          }
                      }
                      LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT);
712
                      rlc_um_data_req(rlc_um_p, frameP, new_sdu_p);
713 714 715 716 717 718 719 720 721 722 723 724

                      //free_mem_block(new_sdu);
                      return RLC_OP_STATUS_OK;
                  } else {
                      return RLC_OP_STATUS_BAD_PARAMETER;
                  }
              } else {
                  return RLC_OP_STATUS_BAD_PARAMETER;
              }
          } else {
              return RLC_OP_STATUS_BAD_PARAMETER;
          }
725 726 727
  }
#else
  } else {/* MBMS_flag != 0 */
gauthier's avatar
gauthier committed
728
    free_mem_block(sdu_pP);
729
    LOG_E(RLC, "MBMS_flag != 0 while Rel10 is not defined...\n");
730 731
    //handle_event(ERROR,"FILE %s FONCTION rlc_data_req() LINE %s : parameter module_id out of bounds :%d\n", __FILE__, __LINE__, module_idP);
    return RLC_OP_STATUS_BAD_PARAMETER;
732
  }
733
#endif
734 735 736
}

//-----------------------------------------------------------------------------
gauthier's avatar
gauthier committed
737
void rlc_data_ind     (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t enb_flagP, MBMS_flag_t MBMS_flagP, rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t* sdu_pP, boolean_t is_data_planeP) {
738
//-----------------------------------------------------------------------------
gauthier's avatar
gauthier committed
739
  rlc_mode_t             rlc_mode   = RLC_MODE_NONE;
gauthier's avatar
gauthier committed
740

741 742 743 744 745 746 747 748 749 750 751
#ifdef Rel10
  if (MBMS_flagP == TRUE) {
      rlc_mode = RLC_MODE_UM;
  } else
#endif
  {
      if (enb_flagP) {
          rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode;
      } else {
          rlc_mode = rlc_array_ue[ue_mod_idP][rb_idP].mode;
      }
752
  }
gauthier's avatar
gauthier committed
753 754

  LOG_D(RLC, "[FRAME %5u][%s][RLC][INST %u/%u][RB %u] Display of rlc_data_ind: size %u\n",
755
        frameP,
gauthier's avatar
gauthier committed
756
        (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
757 758 759 760 761 762 763 764 765 766 767
        enb_mod_idP,
        ue_mod_idP,
        rb_idP,
        sdu_sizeP);

  rlc_util_print_hex_octets(RLC, (unsigned char*)sdu_pP->data, sdu_sizeP);
    // now demux is done at PDCP
    //  if ((is_data_planeP)) {


  switch (rlc_mode) {
gauthier's avatar
gauthier committed
768 769 770
      case RLC_MODE_NONE:
        break;
      case RLC_MODE_AM:
gauthier's avatar
gauthier committed
771
          LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][INST %u/%u][RB %u][--- RLC_DATA_IND/%d Bytes --->][PDCP][INST %u/%u][RB %u]\n",
772
                   frameP,
gauthier's avatar
gauthier committed
773
                   (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
774 775 776 777 778 779 780 781
                   enb_mod_idP,
                   ue_mod_idP,
                   rb_idP,
                   sdu_sizeP,
                   enb_mod_idP,
                   ue_mod_idP,
                   rb_idP);
          break;
gauthier's avatar
gauthier committed
782
      case RLC_MODE_UM:
783
          LOG_D(RLC, "[FRAME %5u][%s][RLC_UM][INST %u/%u][RB %u][--- RLC_DATA_IND %s/%d Bytes --->][PDCP][INST %u/%u][RB %u]\n",
784
                   frameP,
gauthier's avatar
gauthier committed
785
                   (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
786 787 788
                   enb_mod_idP,
                   ue_mod_idP,
                   rb_idP,
789
                   (MBMS_flagP) ? "(e-MBMS)" : "",
gauthier's avatar
gauthier committed
790 791 792 793 794
                   sdu_sizeP,
                   enb_mod_idP,
                   ue_mod_idP,
                   rb_idP);
          break;
gauthier's avatar
gauthier committed
795
      case RLC_MODE_TM:
gauthier's avatar
gauthier committed
796
          LOG_D(RLC, "[FRAME %5u][%s][RLC_TM][INST %u/%u][RB %u][--- RLC_DATA_IND/%d Bytes --->][PDCP][INST %u/%u][RB %u]\n",
797
                 frameP,
gauthier's avatar
gauthier committed
798
                 (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
799 800 801 802 803 804 805 806 807
                 enb_mod_idP,
                 ue_mod_idP,
                 rb_idP,
                 sdu_sizeP,
                 enb_mod_idP,
                 ue_mod_idP,
                 rb_idP);
          break;
  }
808
  pdcp_data_ind (enb_mod_idP, ue_mod_idP, frameP, enb_flagP, MBMS_flagP, rb_idP, sdu_sizeP, sdu_pP, is_data_planeP);
809 810
}
//-----------------------------------------------------------------------------
gauthier's avatar
gauthier committed
811 812 813
void rlc_data_conf     (module_id_t     enb_mod_idP,
                        module_id_t     ue_mod_idP,
                        frame_t         frameP,
gauthier's avatar
gauthier committed
814
                        eNB_flag_t      enb_flagP,
gauthier's avatar
gauthier committed
815 816 817 818
                        rb_id_t         rb_idP,
                        mui_t           muiP,
                        rlc_tx_status_t statusP,
                        boolean_t       is_data_planeP) {
819
//-----------------------------------------------------------------------------
gauthier's avatar
gauthier committed
820
    rlc_mode_t             rlc_mode   = RLC_MODE_NONE;
gauthier's avatar
gauthier committed
821

822 823 824 825 826 827 828 829 830 831 832 833 834 835
//TO DO (check if we can add MBMS flag in prototype)#ifdef Rel10
//  if (MBMS_flagP == TRUE) {
//      rlc_mode = RLC_MODE_UM;
//  } else
//#endif
#if !defined(Rel10)
  {
      if (enb_flagP) {
          rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode;
      } else {
          rlc_mode = rlc_array_ue[ue_mod_idP][rb_idP].mode;
      }
  }
#endif
836 837
    if (!(is_data_planeP)) {
        if (rlc_rrc_data_conf != NULL) {
838
#if !defined(Rel10)
839
            LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED);
gauthier's avatar
gauthier committed
840
            switch (rlc_mode) {
gauthier's avatar
gauthier committed
841 842 843
                case RLC_MODE_NONE:
                    break;
                case RLC_MODE_AM:
gauthier's avatar
gauthier committed
844
                    LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][INST %u/%u][RB %u][--- RLC_DATA_CONF /MUI %d --->][RRC][INST %u/%u][][RLC_DATA_CONF/ MUI %d]\n",
845
                            frameP,
gauthier's avatar
gauthier committed
846
                            (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
847 848
                            enb_mod_idP,
                            ue_mod_idP,
849
                            rb_idP,
gauthier's avatar
gauthier committed
850 851 852 853
                            muiP,
                            enb_mod_idP,
                            ue_mod_idP,
                            muiP);
854
                    break;
gauthier's avatar
gauthier committed
855
                case RLC_MODE_UM:
gauthier's avatar
gauthier committed
856
                    LOG_D(RLC, "[FRAME %5u][%s][RLC_UM][INST %u/%u][RB %u][--- RLC_DATA_CONF /MUI %d --->][RRC][INST %u/%u][][RLC_DATA_CONF/ MUI %d]\n",
857
                            frameP,
gauthier's avatar
gauthier committed
858
                            (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
859 860
                            enb_mod_idP,
                            ue_mod_idP,
861
                            rb_idP,
gauthier's avatar
gauthier committed
862 863 864 865
                            muiP,
                            enb_mod_idP,
                            ue_mod_idP,
                            muiP);
866
                    break;
gauthier's avatar
gauthier committed
867
                case RLC_MODE_TM:
gauthier's avatar
gauthier committed
868
                    LOG_D(RLC, "[FRAME %5u][%s][RLC_TM][INST %u/%u][RB %u][--- RLC_DATA_CONF /MUI %d --->][RRC][INST %u/%u][][RLC_DATA_CONF/ MUI %d]\n",
869
                            frameP,
gauthier's avatar
gauthier committed
870
                            (enb_flagP) ? "eNB" : "UE",
gauthier's avatar
gauthier committed
871 872
                            enb_mod_idP,
                            ue_mod_idP,
873
                            rb_idP,
gauthier's avatar
gauthier committed
874 875 876 877
                            muiP,
                            enb_mod_idP,
                            ue_mod_idP,
                            muiP);
878 879 880
                    break;
            }
            LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT);
881
#endif
gauthier's avatar
gauthier committed
882
            rlc_rrc_data_conf (enb_mod_idP , ue_mod_idP, enb_flagP, rb_idP , muiP, statusP);
883 884 885 886 887
        }
    }
}
//-----------------------------------------------------------------------------
int
888
rlc_module_init (void)
889 890
{
//-----------------------------------------------------------------------------
gauthier's avatar
gauthier committed
891 892 893 894
   int          k;
   module_id_t  module_id1;
   module_id_t  module_id2;
   rb_id_t      rb_id;
gauthier's avatar
gauthier committed
895 896 897 898
#if defined(Rel10)
  mbms_session_id_t session_id;
  mbms_service_id_t service_id;
#endif
gauthier's avatar
gauthier committed
899

900 901 902
   LOG_D(RLC, "MODULE INIT\n");
   rlc_rrc_data_ind  = NULL;
   rlc_rrc_data_conf = NULL;
gauthier's avatar
gauthier committed
903 904 905 906 907 908


   for (module_id1=0; module_id1 < NUMBER_OF_UE_MAX; module_id1++) {
       for (k=0; k < RLC_MAX_LC; k++) {
           lcid2rbid_ue[module_id1][k] = RLC_RB_UNALLOCATED;
       }
gauthier's avatar
gauthier committed
909 910 911 912 913 914
#if defined(Rel10)
      for (service_id = 0; service_id < maxServiceCount; service_id++) {
          for (session_id = 0; session_id < maxSessionPerPMCH; session_id++) {
              memset(&rlc_mbms_array_ue[module_id1][service_id][session_id], 0, sizeof(rlc_mbms_t));
          }
      }
915 916 917 918
      for (k=0; k < RLC_MAX_MBMS_LC; k++) {
          rlc_mbms_lcid2service_session_id_ue[module_id1][k].service_id = 0;
          rlc_mbms_lcid2service_session_id_ue[module_id1][k].session_id = 0;
      }
919 920 921
      for (k=0; k < NB_RB_MBMS_MAX; k++) {
          rlc_mbms_rbid2lcid_eNB[module_id1][k] = RLC_LC_UNALLOCATED;
      }
gauthier's avatar
gauthier committed
922
#endif
gauthier's avatar
gauthier committed
923 924 925
       for (rb_id=0; rb_id < NB_RB_MAX; rb_id++) {
           memset(&rlc_array_ue[module_id1][rb_id], 0, sizeof(rlc_t));
       }
926
   }
gauthier's avatar
gauthier committed
927 928

   for (module_id1=0; module_id1 < NUMBER_OF_eNB_MAX; module_id1++) {
gauthier's avatar
gauthier committed
929 930 931 932 933 934
#if defined(Rel10)
      for (service_id = 0; service_id < maxServiceCount; service_id++) {
          for (session_id = 0; session_id < maxSessionPerPMCH; session_id++) {
              memset(&rlc_mbms_array_eNB[module_id1][service_id][session_id], 0, sizeof(rlc_mbms_t));
          }
      }
935 936 937 938
      for (k=0; k < RLC_MAX_MBMS_LC; k++) {
          rlc_mbms_lcid2service_session_id_eNB[module_id1][k].service_id = 0;
          rlc_mbms_lcid2service_session_id_eNB[module_id1][k].session_id = 0;
      }
939 940 941
      for (k=0; k < NB_RB_MBMS_MAX; k++) {
          rlc_mbms_rbid2lcid_ue[module_id1][k] = RLC_LC_UNALLOCATED;
      }
gauthier's avatar
gauthier committed
942
#endif
gauthier's avatar
gauthier committed
943 944 945 946 947 948 949 950 951 952
       for (module_id2=0; module_id2 < NUMBER_OF_UE_MAX; module_id2++) {
           for (rb_id=0; rb_id < NB_RB_MAX; rb_id++) {
               memset(&rlc_array_eNB[module_id1][module_id2][rb_id], 0, sizeof(rlc_t));
           }
           for (k=0; k < RLC_MAX_LC; k++) {
               lcid2rbid_eNB[module_id1][module_id2][k] = RLC_RB_UNALLOCATED;
           }
       }
   }

953 954 955 956 957 958
   pool_buffer_init();

   return(0);
}
//-----------------------------------------------------------------------------
void
959
rlc_module_cleanup (void)
960 961 962 963 964
//-----------------------------------------------------------------------------
{
}
//-----------------------------------------------------------------------------
void
965
rlc_layer_init (void)
966 967 968 969 970
{
//-----------------------------------------------------------------------------
}
//-----------------------------------------------------------------------------
void
971
rlc_layer_cleanup (void)
972 973 974 975
//-----------------------------------------------------------------------------
{
}