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

    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.


    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.

    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/>.

  Contact Information
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
24
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr
Lionel Gauthier's avatar
Lionel 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
Lionel Gauthier's avatar
Lionel Gauthier committed
27 28

 *******************************************************************************/
29 30
#define RLC_UM_MODULE 1
#define RLC_UM_RECEIVER_C 1
31 32 33 34 35 36 37 38 39 40 41
#include "platform_types.h"
//-----------------------------------------------------------------------------
#include "rlc.h"
#include "rlc_um.h"
#include "rlc_um_structs.h"
#include "rlc_primitives.h"
#include "mac_primitives.h"
#include "list.h"
#include "UTIL/LOG/log.h"

//-----------------------------------------------------------------------------
42 43
void
rlc_um_display_rx_window(
44
  const protocol_ctxt_t* const ctxt_pP,
45 46
  rlc_um_entity_t * const rlc_pP
)
47
{
48 49 50 51 52 53 54 55 56 57
  unsigned long sn = 0;
  unsigned long end_sn = 0;
  char          str[4];
  char          time_out_str[11];
  int           str_index;
  char          color[32];

  LOG_T(RLC, "\n");
  LOG_T(RLC, "+-------------------------------------------------------------------------------------------------------+");
  LOG_T(RLC, "\n");
58
  sprintf(time_out_str, "%010d", rlc_pP->t_reordering.ms_duration);
59 60 61 62 63 64 65 66 67 68 69 70 71 72 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
  time_out_str[10] = 0;
  LOG_T(RLC, "| RLC UM RB %02d    VR(UR)=%03d    VR(UX)=%03d    VR(UH)=%03d    t-Reordering: %s %s %s             |",
        rlc_pP->rb_id, rlc_pP->vr_ur, rlc_pP->vr_ux, rlc_pP->vr_uh,
        (rlc_pP->t_reordering.running)?" ON":"OFF",
        (rlc_pP->t_reordering.running)?"Time-out frameP:":"               ",
        (rlc_pP->t_reordering.running)?time_out_str:"          ");
  LOG_T(RLC, "\n");
  LOG_T(RLC, "+------+------------------------------------------------------------------------------------------------+");
  LOG_T(RLC, "\n");
  LOG_T(RLC, "|      |00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |");
  LOG_T(RLC, "\n");
  LOG_T(RLC, "+------+------------------------------------------------------------------------------------------------+");
  LOG_T(RLC, "\n");

  if (rlc_pP->rx_sn_length == 10) {
    end_sn = RLC_UM_SN_10_BITS_MODULO;
  } else {
    end_sn = RLC_UM_SN_5_BITS_MODULO;
  }


  for (sn = 0; sn < end_sn; sn++) {
    str[0]    = ' ';
    str[1]    = ' ';
    str[2]    = ' ';
    str[3]    = 0;
    str_index = 0;

    if ((sn % 32) == 0) {
      if ((sn != 0)) {
        LOG_T(RLC, "%s%s|", RLC_FG_COLOR_DEFAULT, RLC_NORMAL_VIDEO);
        LOG_T(RLC, "\n");
      }

      LOG_T(RLC, "%s%s| %04d |", RLC_FG_COLOR_DEFAULT, RLC_NORMAL_VIDEO, sn);
    }

    strcpy(color, RLC_FG_COLOR_DEFAULT);

    if (sn == rlc_pP->vr_ur) {
      str[str_index++] = 'R';
      strcpy(color, RLC_FG_COLOR_BLUE);
101 102
    }

103 104 105 106
    if (sn == rlc_pP->vr_ux) {
      str[str_index++] = 'X';
      strcpy(color, RLC_FG_COLOR_ORANGE);
    }
107

108 109 110
    if (sn == rlc_pP->vr_uh) {
      str[str_index++] = 'H';
      strcpy(color, RLC_FG_COLOR_RED);
111
    }
112

113
    if (rlc_um_get_pdu_from_dar_buffer(ctxt_pP, rlc_pP, sn)) {
114
      // test RLC_REVERSE_VIDEO
115 116 117
      if (str_index <= 2) {
        str[str_index] = '.';
      }
118 119 120 121 122 123 124 125 126 127 128

      LOG_T(RLC, "%s%s%s", color, RLC_REVERSE_VIDEO, str);
    } else {
      LOG_T(RLC, "%s%s%s", color, RLC_NORMAL_VIDEO, str);
    }
  }

  LOG_T(RLC, "%s%s|", RLC_FG_COLOR_DEFAULT, RLC_NORMAL_VIDEO);
  LOG_T(RLC, "\n");
  LOG_T(RLC, "+------+------------------------------------------------------------------------------------------------+");
  LOG_T(RLC, "\n");
129 130 131 132
}

//-----------------------------------------------------------------------------
void
133
rlc_um_receive (
134
  const protocol_ctxt_t* const ctxt_pP,
135 136
  rlc_um_entity_t * const rlc_pP,
  struct mac_data_ind data_indP)
137 138
{

139 140 141
  mem_block_t        *tb_p             = NULL;
  uint8_t               *first_byte_p     = NULL;
  uint16_t               tb_size_in_bytes = 0;
142

143
  while ((tb_p = list_remove_head (&data_indP.data))) {
144

145 146
    first_byte_p = ((struct mac_tb_ind *) (tb_p->data))->data_ptr;
    tb_size_in_bytes = ((struct mac_tb_ind *) (tb_p->data))->size;
147

148 149
    rlc_pP->stat_rx_data_bytes += tb_size_in_bytes;
    rlc_pP->stat_rx_data_pdu   += 1;
150

151
    if (tb_size_in_bytes > 0) {
152 153 154 155
      rlc_um_receive_process_dar (ctxt_pP, rlc_pP, tb_p, (rlc_um_pdu_sn_10_t*)first_byte_p, tb_size_in_bytes);
#if defined(TRACE_RLC_UM_RX)
      LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n",
            PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP),
156 157 158 159
            rlc_pP->vr_ur,
            rlc_pP->vr_ux,
            rlc_pP->vr_uh);
      //rlc_um_display_rx_window(rlc_pP); commented because bad display
160
#endif
161
    }
162
  }
163
}