rlc.c 23.1 KB
Newer Older
gauthier's avatar
gauthier committed
1 2 3 4 5 6 7
/*
                                rlc.c
                             -------------------
  AUTHOR  : Lionel GAUTHIER
  COMPANY : EURECOM
  EMAIL   : Lionel.Gauthier at eurecom dot fr
*/
8 9 10 11 12
#define RLC_C
#include "rlc.h"
#include "mem_block.h"
#include "../MAC/extern.h"
#include "UTIL/LOG/log.h"
gauthier's avatar
gauthier committed
13
#include "UTIL/OCG/OCG_vars.h"
14
#include "UTIL/LOG/vcd_signal_dumper.h"
15 16 17

#include "assertions.h"

18
extern boolean_t pdcp_data_ind(
19 20 21 22 23 24
  const protocol_ctxt_t* const ctxt_pP,
  const srb_flag_t srb_flagP,
  const MBMS_flag_t MBMS_flagP,
  const rb_id_t rb_idP,
  const sdu_size_t sdu_buffer_sizeP,
  mem_block_t* const sdu_buffer_pP);
25

26
#define DEBUG_RLC_PDCP_INTERFACE 1
27
//#define TRACE_RLC_PAYLOAD 1
gauthier's avatar
gauthier committed
28
#define DEBUG_RLC_DATA_REQ 1
29 30

//-----------------------------------------------------------------------------
31
void rlc_util_print_hex_octets(comp_name_t componentP, unsigned char* dataP, const signed long sizeP)
32 33 34 35 36 37 38 39 40
//-----------------------------------------------------------------------------
{
  unsigned long octet_index = 0;

  if (dataP == NULL) {
    return;
  }


41 42 43 44 45


  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");
46

47
  for (octet_index = 0; octet_index < sizeP; octet_index++) {
48
    if ((octet_index % 16) == 0) {
49
      if (octet_index != 0) {
50
        LOG_T(componentP, " |\n");
51
      }
52

53 54
      LOG_T(componentP, " %04d |", octet_index);
    }
55

56 57 58 59 60 61 62 63 64 65 66 67 68
    /*
     * 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;
69

70
  for (index = octet_index; index < 16; ++index) {
71
    LOG_T(componentP, "   ");
72
  }
73

74 75
  LOG_T(componentP, " |\n");
}
76

77
//-----------------------------------------------------------------------------
gauthier's avatar
gauthier committed
78
rlc_op_status_t rlc_stat_req     (
79
  const protocol_ctxt_t* const ctxt_pP,
80 81
  const srb_flag_t    srb_flagP,
  const rb_id_t       rb_idP,
82
  unsigned int* stat_rlc_mode,
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 112 113
  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)
{
  //-----------------------------------------------------------------------------
  rlc_mode_t             rlc_mode        = RLC_MODE_NONE;
  rlc_union_t           *rlc_union_p     = NULL;
114
  hash_key_t             key             = HASHTABLE_NOT_A_KEY_VALUE;
115
  hashtable_rc_t         h_rc;
gauthier's avatar
gauthier committed
116 117

#ifdef OAI_EMU
118

119
  CHECK_CTXT_ARGS(ctxt_pP)
120

gauthier's avatar
gauthier committed
121
#endif
122
  AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX);
123
  key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP);
124 125 126 127 128
  h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p);

  if (h_rc == HASH_TABLE_OK) {
    rlc_mode = rlc_union_p->mode;
  }
129
  *stat_rlc_mode                     = rlc_mode;
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
  switch (rlc_mode) {
  case RLC_MODE_NONE:
    *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;

  case RLC_MODE_AM:
163
    rlc_am_stat_req(ctxt_pP,
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
                    &rlc_union_p->rlc.am,
                    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;

  case RLC_MODE_UM:
    *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;
208
    rlc_um_stat_req (ctxt_pP,
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 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 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
                     &rlc_union_p->rlc.um,
                     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;

  case RLC_MODE_TM:
    *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;
  }
291
}
292

293
//-----------------------------------------------------------------------------
294
rlc_op_status_t rlc_data_req     (const protocol_ctxt_t* const ctxt_pP,
295 296 297 298
                                  const srb_flag_t   srb_flagP,
                                  const MBMS_flag_t  MBMS_flagP,
                                  const rb_id_t      rb_idP,
                                  const mui_t        muiP,
299 300
                                  confirm_t    confirmP,
                                  sdu_size_t   sdu_sizeP,
301 302 303
                                  mem_block_t *sdu_pP)
{
  //-----------------------------------------------------------------------------
304
  mem_block_t           *new_sdu_p    = NULL;
gauthier's avatar
gauthier committed
305
  rlc_mode_t             rlc_mode     = RLC_MODE_NONE;
306
  rlc_union_t           *rlc_union_p = NULL;
307
  hash_key_t             key         = HASHTABLE_NOT_A_KEY_VALUE;
308 309
  hashtable_rc_t         h_rc;

310
#ifdef Rel10
311 312
  rlc_mbms_id_t         *mbms_id_p  = NULL;
  logical_chan_id_t      log_ch_id  = 0;
313 314
#endif
#ifdef DEBUG_RLC_DATA_REQ
Cedric Roux's avatar
typo  
Cedric Roux committed
315
  LOG_D(RLC,PROTOCOL_CTXT_FMT"rlc_data_req:  rb_id %u (MAX %d), muip %d, confirmP %d, sdu_sizeP %d, sdu_pP %p\n",
316
        PROTOCOL_CTXT_ARGS(ctxt_pP),
gauthier's avatar
gauthier committed
317 318 319 320 321 322
        rb_idP,
        NB_RAB_MAX,
        muiP,
        confirmP,
        sdu_sizeP,
        sdu_pP);
323
#endif
324 325
#ifdef Rel10
#else
gauthier's avatar
gauthier committed
326
  AssertFatal(MBMS_flagP == 0, "MBMS_flagP %u", MBMS_flagP);
327
#endif
gauthier's avatar
gauthier committed
328
#ifdef OAI_EMU
329

330
  CHECK_CTXT_ARGS(ctxt_pP)
331

gauthier's avatar
gauthier committed
332
#endif
333

Cedric Roux's avatar
Cedric Roux committed
334 335 336 337 338
#if T_TRACER
  if (ctxt_pP->enb_flag)
    T(T_ENB_RLC_DL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_sizeP));
#endif

339
  if (MBMS_flagP) {
340
    AssertFatal (rb_idP < NB_RB_MBMS_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MBMS_MAX);
341
  } else {
342
    AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX);
343
  }
344

gauthier's avatar
gauthier committed
345
  DevAssert(sdu_pP != NULL);
346 347 348 349 350 351
  DevCheck(sdu_sizeP > 0, sdu_sizeP, 0, 0);

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

gauthier's avatar
gauthier committed
352
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_IN);
353

354
#ifdef Rel10
355

356
  if (MBMS_flagP == TRUE) {
357 358 359
    if (ctxt_pP->enb_flag) {
      log_ch_id = rlc_mbms_enb_get_lcid_by_rb_id(ctxt_pP->module_id,rb_idP);
      mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[ctxt_pP->module_id][log_ch_id];
360
    } else {
361 362
      log_ch_id = rlc_mbms_ue_get_lcid_by_rb_id(ctxt_pP->rnti,rb_idP);
      mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[ctxt_pP->rnti][log_ch_id];
363 364
    }

365
    key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_id_p->service_id, mbms_id_p->session_id);
366 367 368
  } else
#endif
  {
369
    key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP);
370 371 372
  }

  h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p);
373

374
  if (h_rc == HASH_TABLE_OK) {
375
    rlc_mode = rlc_union_p->mode;
376
  } else {
377 378
    rlc_mode = RLC_MODE_NONE;
    AssertFatal (0 , "RLC not configured key %ju\n", key);
gauthier's avatar
gauthier committed
379 380
  }

381
  if (MBMS_flagP == 0) {
382 383
    LOG_D(RLC, PROTOCOL_CTXT_FMT"[RB %u] Display of rlc_data_req:\n",
          PROTOCOL_CTXT_ARGS(ctxt_pP),
gauthier's avatar
gauthier committed
384
          rb_idP);
385
#if defined(TRACE_RLC_PAYLOAD)
386
    rlc_util_print_hex_octets(RLC, (unsigned char*)sdu_pP->data, sdu_sizeP);
387
#endif
388 389

#ifdef DEBUG_RLC_DATA_REQ
Cedric Roux's avatar
typo  
Cedric Roux committed
390
    LOG_D(RLC,"RLC_TYPE : %d\n", rlc_mode);
391
#endif
392 393 394 395

    switch (rlc_mode) {
    case RLC_MODE_NONE:
      free_mem_block(sdu_pP);
396 397
      LOG_E(RLC, PROTOCOL_CTXT_FMT" Received RLC_MODE_NONE as rlc_type for rb_id %u\n",
            PROTOCOL_CTXT_ARGS(ctxt_pP),
398
            rb_idP);
gauthier's avatar
gauthier committed
399
      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT);
400 401 402
      return RLC_OP_STATUS_BAD_PARAMETER;

    case RLC_MODE_AM:
403
#ifdef DEBUG_RLC_DATA_REQ
404
      msg("RLC_MODE_AM\n");
405
#endif
406 407 408 409 410 411 412 413 414 415 416 417
      new_sdu_p = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_am_data_req_alloc));

      if (new_sdu_p != NULL) {
        // PROCESS OF COMPRESSION HERE:
        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);

        ((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);
        free_mem_block(sdu_pP);
418
        rlc_am_data_req(ctxt_pP, &rlc_union_p->rlc.am, new_sdu_p);
gauthier's avatar
gauthier committed
419
        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT);
420 421
        return RLC_OP_STATUS_OK;
      } else {
gauthier's avatar
gauthier committed
422
        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT);
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
        return RLC_OP_STATUS_INTERNAL_ERROR;
      }

      break;

    case RLC_MODE_UM:
      new_sdu_p = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_um_data_req_alloc));

      if (new_sdu_p != NULL) {
        // PROCESS OF COMPRESSION HERE:
        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);
        free_mem_block(sdu_pP);

440
        rlc_um_data_req(ctxt_pP, &rlc_union_p->rlc.um, new_sdu_p);
441 442

        //free_mem_block(new_sdu);
gauthier's avatar
gauthier committed
443
        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT);
444 445
        return RLC_OP_STATUS_OK;
      } else {
gauthier's avatar
gauthier committed
446
        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT);
447 448
        return RLC_OP_STATUS_INTERNAL_ERROR;
      }
gauthier's avatar
gauthier committed
449

450 451 452 453 454 455 456 457 458 459 460 461 462
      break;

    case RLC_MODE_TM:
      new_sdu_p = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_tm_data_req_alloc));

      if (new_sdu_p != NULL) {
        // PROCESS OF COMPRESSION HERE:
        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);

        ((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);
        free_mem_block(sdu_pP);
463
        rlc_tm_data_req(ctxt_pP, &rlc_union_p->rlc.tm, new_sdu_p);
gauthier's avatar
gauthier committed
464
        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT);
465 466 467
        return RLC_OP_STATUS_OK;
      } else {
        //handle_event(ERROR,"FILE %s FONCTION rlc_data_req() LINE %s : out of memory\n", __FILE__, __LINE__);
gauthier's avatar
gauthier committed
468
        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT);
469
        return RLC_OP_STATUS_INTERNAL_ERROR;
gauthier's avatar
gauthier committed
470
      }
471

472 473 474 475
      break;

    default:
      free_mem_block(sdu_pP);
gauthier's avatar
gauthier committed
476
      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT);
477 478 479 480
      return RLC_OP_STATUS_INTERNAL_ERROR;

    }

481
#ifdef Rel10
482
  } else { /* MBMS_flag != 0 */
483 484 485 486 487 488 489 490 491 492 493 494 495
    //  LOG_I(RLC,"DUY rlc_data_req: mbms_rb_id in RLC instant is: %d\n", mbms_rb_id);
    if (sdu_pP != NULL) {
      if (sdu_sizeP > 0) {
        LOG_I(RLC,"received a packet with size %d for MBMS \n", sdu_sizeP);
        new_sdu_p = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_um_data_req_alloc));

        if (new_sdu_p != NULL) {
          // PROCESS OF COMPRESSION HERE:
          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);
          free_mem_block(sdu_pP);
496
          rlc_um_data_req(ctxt_pP, &rlc_union_p->rlc.um, new_sdu_p);
497 498

          //free_mem_block(new_sdu);
gauthier's avatar
gauthier committed
499
          VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT);
500 501
          return RLC_OP_STATUS_OK;
        } else {
gauthier's avatar
gauthier committed
502
          VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT);
503 504 505
          return RLC_OP_STATUS_BAD_PARAMETER;
        }
      } else {
gauthier's avatar
gauthier committed
506
        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT);
507 508 509
        return RLC_OP_STATUS_BAD_PARAMETER;
      }
    } else {
gauthier's avatar
gauthier committed
510
      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT);
511 512
      return RLC_OP_STATUS_BAD_PARAMETER;
    }
513
  }
514

515
#else
516 517 518
  }
  else  /* MBMS_flag != 0 */
  {
gauthier's avatar
gauthier committed
519
    free_mem_block(sdu_pP);
520
    LOG_E(RLC, "MBMS_flag != 0 while Rel10 is not defined...\n");
521
    //handle_event(ERROR,"FILE %s FONCTION rlc_data_req() LINE %s : parameter module_id out of bounds :%d\n", __FILE__, __LINE__, module_idP);
gauthier's avatar
gauthier committed
522
    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT);
523
    return RLC_OP_STATUS_BAD_PARAMETER;
524
  }
525

526
#endif
527 528 529
}

//-----------------------------------------------------------------------------
530
void rlc_data_ind     (
531
  const protocol_ctxt_t* const ctxt_pP,
532 533 534 535 536 537 538
  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      *sdu_pP)
{
  //-----------------------------------------------------------------------------
gauthier's avatar
gauthier committed
539 540


541 542 543
#if defined(TRACE_RLC_PAYLOAD)
  LOG_D(RLC, PROTOCOL_CTXT_FMT"[%s %u] Display of rlc_data_ind: size %u\n",
        PROTOCOL_CTXT_ARGS(ctxt_pP),
544
        (srb_flagP) ? "SRB" : "DRB",
gauthier's avatar
gauthier committed
545 546 547 548
        rb_idP,
        sdu_sizeP);

  rlc_util_print_hex_octets(RLC, (unsigned char*)sdu_pP->data, sdu_sizeP);
549
#endif
550

Cedric Roux's avatar
Cedric Roux committed
551 552 553 554 555 556
#if T_TRACER
  if (ctxt_pP->enb_flag)
    T(T_ENB_RLC_UL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_sizeP));
#endif


557
  pdcp_data_ind (
558
    ctxt_pP,
559 560 561 562 563
    srb_flagP,
    MBMS_flagP,
    rb_idP,
    sdu_sizeP,
    sdu_pP);
564 565
}
//-----------------------------------------------------------------------------
566
void rlc_data_conf     (const protocol_ctxt_t* const ctxt_pP,
567 568 569
                        const srb_flag_t      srb_flagP,
                        const rb_id_t         rb_idP,
                        const mui_t           muiP,
570 571 572 573 574 575
                        const rlc_tx_status_t statusP)
{
  //-----------------------------------------------------------------------------

  if (srb_flagP) {
    if (rlc_rrc_data_conf != NULL) {
576
      rlc_rrc_data_conf (ctxt_pP, rb_idP , muiP, statusP);
577
    }
578
  }
579 580 581
}
//-----------------------------------------------------------------------------
int
582
rlc_module_init (void)
583
{
584 585 586
  //-----------------------------------------------------------------------------
  int          k;
  module_id_t  module_id1;
gauthier's avatar
gauthier committed
587

Cedric Roux's avatar
Cedric Roux committed
588 589 590
  /* for no gcc warnings */
  (void)k;

591 592 593
  LOG_D(RLC, "MODULE INIT\n");
  rlc_rrc_data_ind  = NULL;
  rlc_rrc_data_conf = NULL;
gauthier's avatar
gauthier committed
594

595 596
  rlc_coll_p = hashtable_create ((maxDRB + 2) * 16, NULL, rb_free_rlc_union);
  AssertFatal(rlc_coll_p != NULL, "UNRECOVERABLE error, RLC hashtable_create failed");
gauthier's avatar
gauthier committed
597

598
  for (module_id1=0; module_id1 < NUMBER_OF_UE_MAX; module_id1++) {
gauthier's avatar
gauthier committed
599
#if defined(Rel10)
600 601 602 603 604 605 606

    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;
    }

    for (k=0; k < NB_RB_MBMS_MAX; k++) {
607
      rlc_mbms_rbid2lcid_ue[module_id1][k] = RLC_LC_UNALLOCATED;
608 609
    }

gauthier's avatar
gauthier committed
610
#endif
611
  }
gauthier's avatar
gauthier committed
612

613
  for (module_id1=0; module_id1 < NUMBER_OF_eNB_MAX; module_id1++) {
gauthier's avatar
gauthier committed
614
#if defined(Rel10)
615 616 617 618 619 620 621

    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;
    }

    for (k=0; k < NB_RB_MBMS_MAX; k++) {
622
      rlc_mbms_rbid2lcid_eNB[module_id1][k] = RLC_LC_UNALLOCATED;
623 624
    }

gauthier's avatar
gauthier committed
625
#endif
626
  }
gauthier's avatar
gauthier committed
627

628
  pool_buffer_init();
629

630
  return(0);
631 632 633
}
//-----------------------------------------------------------------------------
void
634
rlc_module_cleanup (void)
635 636
//-----------------------------------------------------------------------------
{
637
  hashtable_destroy(rlc_coll_p);
638 639 640
}
//-----------------------------------------------------------------------------
void
641
rlc_layer_init (void)
642
{
643
  //-----------------------------------------------------------------------------
644 645 646
}
//-----------------------------------------------------------------------------
void
647
rlc_layer_cleanup (void)
648 649 650 651
//-----------------------------------------------------------------------------
{
}