eNB_scheduler_dlsch.c 58.7 KB
Newer Older
1 2 3 4 5
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
Cedric Roux's avatar
Cedric Roux committed
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
7 8 9 10 11 12 13 14 15 16 17 18 19 20
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */
nikaeinn's avatar
nikaeinn committed
21 22 23

/*! \file eNB_scheduler_dlsch.c
 * \brief procedures related to eNB for the DLSCH transport channel
24
 * \author  Navid Nikaein and Raymond Knopp
nikaeinn's avatar
nikaeinn committed
25
 * \date 2010 - 2014
26
 * \email: navid.nikaein@eurecom.fr
nikaeinn's avatar
nikaeinn committed
27
 * \version 1.0
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
 * @ingroup _mac

 */

#include "assertions.h"
#include "PHY/defs.h"
#include "PHY/extern.h"

#include "SCHED/defs.h"
#include "SCHED/extern.h"

#include "LAYER2/MAC/defs.h"
#include "LAYER2/MAC/proto.h"
#include "LAYER2/MAC/extern.h"
#include "UTIL/LOG/log.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
#include "UTIL/OPT/opt.h"
#include "OCG.h"
#include "OCG_extern.h"

#include "RRC/LITE/extern.h"
#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"

//#include "LAYER2/MAC/pre_processor.c"
#include "pdcp.h"

54 55
#include "SIMULATION/TOOLS/defs.h" // for taus

56 57 58 59
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
#endif

Cedric Roux's avatar
Cedric Roux committed
60 61
#include "T.h"

62
#define ENABLE_MAC_PAYLOAD_DEBUG
knopp's avatar
 
knopp committed
63
//#define DEBUG_eNB_SCHEDULER 1
64

65
extern RAN_CONTEXT_t RC;
66

67 68 69 70 71 72 73 74 75 76
//------------------------------------------------------------------------------
void
add_ue_dlsch_info(
  module_id_t module_idP,
  int CC_id,
  int UE_id,
  sub_frame_t subframeP,
  UE_DLSCH_STATUS status
)
//------------------------------------------------------------------------------
77
{
78
  //LOG_D(MAC, "%s(module_idP:%d, CC_id:%d, UE_id:%d, subframeP:%d, status:%d) serving_num:%d rnti:%x\n", __FUNCTION__, module_idP, CC_id, UE_id, subframeP, status, eNB_dlsch_info[module_idP][CC_id][UE_id].serving_num, UE_RNTI(module_idP,UE_id));
79

80 81 82 83
  eNB_dlsch_info[module_idP][CC_id][UE_id].rnti             = UE_RNTI(module_idP,UE_id);
  //  eNB_dlsch_info[module_idP][CC_id][ue_mod_idP].weight           = weight;
  eNB_dlsch_info[module_idP][CC_id][UE_id].subframe         = subframeP;
  eNB_dlsch_info[module_idP][CC_id][UE_id].status           = status;
84

85
  eNB_dlsch_info[module_idP][CC_id][UE_id].serving_num++;
86 87 88

}

89 90 91 92 93 94 95 96
//------------------------------------------------------------------------------
int
schedule_next_dlue(
  module_id_t module_idP,
  int CC_id,
  sub_frame_t subframeP
)
//------------------------------------------------------------------------------
97
{
98

knopp's avatar
 
knopp committed
99
  int next_ue;
100
  UE_list_t *UE_list=&RC.mac[module_idP]->UE_list;
101

102
  for (next_ue=UE_list->head; next_ue>=0; next_ue=UE_list->next[next_ue] ) {
103
    if  (eNB_dlsch_info[module_idP][CC_id][next_ue].status == S_DL_WAITING) {
knopp's avatar
 
knopp committed
104
      return next_ue;
105
    }
106
  }
107 108

  for (next_ue=UE_list->head; next_ue>=0; next_ue=UE_list->next[next_ue] ) {
109 110
    if  (eNB_dlsch_info[module_idP][CC_id][next_ue].status == S_DL_BUFFERED) {
      eNB_dlsch_info[module_idP][CC_id][next_ue].status = S_DL_WAITING;
111
    }
knopp's avatar
 
knopp committed
112 113 114
  }

  return(-1);//next_ue;
115 116 117

}

118 119 120
//------------------------------------------------------------------------------
unsigned char
generate_dlsch_header(
121 122 123 124 125
  unsigned char* mac_header,
  unsigned char num_sdus,
  unsigned short *sdu_lengths,
  unsigned char *sdu_lcids,
  unsigned char drx_cmd,
126
  unsigned short timing_advance_cmd,
127 128 129
  unsigned char *ue_cont_res_id,
  unsigned char short_padding,
  unsigned short post_padding
130 131
)
//------------------------------------------------------------------------------
132
{
133 134 135 136 137 138 139 140 141 142

  SCH_SUBHEADER_FIXED *mac_header_ptr = (SCH_SUBHEADER_FIXED *)mac_header;
  uint8_t first_element=0,last_size=0,i;
  uint8_t mac_header_control_elements[16],*ce_ptr;

  ce_ptr = &mac_header_control_elements[0];

  // compute header components

  if ((short_padding == 1) || (short_padding == 2)) {
knopp's avatar
 
knopp committed
143 144 145 146 147
    mac_header_ptr->R    = 0;
    mac_header_ptr->E    = 0;
    mac_header_ptr->LCID = SHORT_PADDING;
    first_element=1;
    last_size=1;
148
  }
149

150
  if (short_padding == 2) {
knopp's avatar
 
knopp committed
151 152 153 154 155 156
    mac_header_ptr->E = 1;
    mac_header_ptr++;
    mac_header_ptr->R = 0;
    mac_header_ptr->E    = 0;
    mac_header_ptr->LCID = SHORT_PADDING;
    last_size=1;
157 158 159
  }

  if (drx_cmd != 255) {
knopp's avatar
 
knopp committed
160 161 162
    if (first_element>0) {
      mac_header_ptr->E = 1;
      mac_header_ptr++;
163
    } else {
knopp's avatar
 
knopp committed
164 165
      first_element=1;
    }
166

knopp's avatar
 
knopp committed
167 168 169 170
    mac_header_ptr->R = 0;
    mac_header_ptr->E    = 0;
    mac_header_ptr->LCID = DRX_CMD;
    last_size=1;
171 172
  }

Cedric Roux's avatar
Cedric Roux committed
173
  if (timing_advance_cmd != 31) {
knopp's avatar
 
knopp committed
174 175 176
    if (first_element>0) {
      mac_header_ptr->E = 1;
      mac_header_ptr++;
177
    } else {
knopp's avatar
 
knopp committed
178 179
      first_element=1;
    }
180

knopp's avatar
 
knopp committed
181 182 183 184 185 186
    mac_header_ptr->R = 0;
    mac_header_ptr->E    = 0;
    mac_header_ptr->LCID = TIMING_ADV_CMD;
    last_size=1;
    //    msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr);
    ((TIMING_ADVANCE_CMD *)ce_ptr)->R=0;
187 188
    AssertFatal(timing_advance_cmd < 64,"timing_advance_cmd %d > 63\n",timing_advance_cmd);
    ((TIMING_ADVANCE_CMD *)ce_ptr)->TA=timing_advance_cmd;//(timing_advance_cmd+31)&0x3f;
knopp's avatar
 
knopp committed
189
    LOG_D(MAC,"timing advance =%d (%d)\n",timing_advance_cmd,((TIMING_ADVANCE_CMD *)ce_ptr)->TA);
knopp's avatar
 
knopp committed
190 191
    ce_ptr+=sizeof(TIMING_ADVANCE_CMD);
    //msg("offset %d\n",ce_ptr-mac_header_control_elements);
192 193 194
  }

  if (ue_cont_res_id) {
knopp's avatar
 
knopp committed
195 196 197
    if (first_element>0) {
      mac_header_ptr->E = 1;
      /*
198 199 200 201
      printf("[eNB][MAC] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr,
      ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R,
      ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E,
      ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID);
knopp's avatar
 
knopp committed
202 203
      */
      mac_header_ptr++;
204
    } else {
knopp's avatar
 
knopp committed
205 206
      first_element=1;
    }
207

knopp's avatar
 
knopp committed
208 209 210 211
    mac_header_ptr->R = 0;
    mac_header_ptr->E    = 0;
    mac_header_ptr->LCID = UE_CONT_RES;
    last_size=1;
212

knopp's avatar
 
knopp committed
213
    LOG_T(MAC,"[eNB ][RAPROC] Generate contention resolution msg: %x.%x.%x.%x.%x.%x\n",
214 215 216 217 218 219 220
          ue_cont_res_id[0],
          ue_cont_res_id[1],
          ue_cont_res_id[2],
          ue_cont_res_id[3],
          ue_cont_res_id[4],
          ue_cont_res_id[5]);

knopp's avatar
 
knopp committed
221 222 223
    memcpy(ce_ptr,ue_cont_res_id,6);
    ce_ptr+=6;
    // msg("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements);
224 225 226 227
  }

  //msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr);

228
  for (i=0; i<num_sdus; i++) {
knopp's avatar
 
knopp committed
229
    LOG_T(MAC,"[eNB] Generate DLSCH header num sdu %d len sdu %d\n",num_sdus, sdu_lengths[i]);
230

knopp's avatar
 
knopp committed
231 232 233
    if (first_element>0) {
      mac_header_ptr->E = 1;
      /*msg("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr,
234 235 236
      ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R,
      ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E,
      ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID);
knopp's avatar
 
knopp committed
237 238 239
      */
      mac_header_ptr+=last_size;
      //msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr);
240
    } else {
knopp's avatar
 
knopp committed
241 242
      first_element=1;
    }
243

knopp's avatar
 
knopp committed
244 245 246 247 248 249 250
    if (sdu_lengths[i] < 128) {
      ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->R    = 0;
      ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->E    = 0;
      ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F    = 0;
      ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->LCID = sdu_lcids[i];
      ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L    = (unsigned char)sdu_lengths[i];
      last_size=2;
251
    } else {
knopp's avatar
 
knopp committed
252 253 254 255 256 257 258 259
      ((SCH_SUBHEADER_LONG *)mac_header_ptr)->R    = 0;
      ((SCH_SUBHEADER_LONG *)mac_header_ptr)->E    = 0;
      ((SCH_SUBHEADER_LONG *)mac_header_ptr)->F    = 1;
      ((SCH_SUBHEADER_LONG *)mac_header_ptr)->LCID = sdu_lcids[i];
      ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB    = ((unsigned short) sdu_lengths[i]>>8)&0x7f;
      ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB    = (unsigned short) sdu_lengths[i]&0xff;
      ((SCH_SUBHEADER_LONG *)mac_header_ptr)->padding   = 0x00;
      last_size=3;
260
#ifdef DEBUG_HEADER_PARSING
knopp's avatar
 
knopp committed
261
      LOG_D(MAC,"[eNB] generate long sdu, size %x (MSB %x, LSB %x)\n",
262 263 264
            sdu_lengths[i],
            ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB,
            ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB);
265
#endif
knopp's avatar
 
knopp committed
266
    }
267
  }
268

269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
  /*

    printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr);

    printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr,
    ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R,
    ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E,
    ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID);


    if (((SCH_SUBHEADER_FIXED*)mac_header_ptr)->LCID < UE_CONT_RES) {
    if (((SCH_SUBHEADER_SHORT*)mac_header_ptr)->F == 0)
    printf("F = 0, sdu len (L field) %d\n",(((SCH_SUBHEADER_SHORT*)mac_header_ptr)->L));
    else
    printf("F = 1, sdu len (L field) %d\n",(((SCH_SUBHEADER_LONG*)mac_header_ptr)->L));
    }
knopp's avatar
 
knopp committed
285
  */
286
  if (post_padding>0) {// we have lots of padding at the end of the packet
knopp's avatar
 
knopp committed
287 288 289 290 291 292 293
    mac_header_ptr->E = 1;
    mac_header_ptr+=last_size;
    // add a padding element
    mac_header_ptr->R    = 0;
    mac_header_ptr->E    = 0;
    mac_header_ptr->LCID = SHORT_PADDING;
    mac_header_ptr++;
294
  } else { // no end of packet padding
knopp's avatar
 
knopp committed
295 296
    // last SDU subhead is of fixed type (sdu length implicitly to be computed at UE)
    mac_header_ptr++;
297 298 299 300 301
  }

  //msg("After subheaders %d\n",(uint8_t*)mac_header_ptr - mac_header);

  if ((ce_ptr-mac_header_control_elements) > 0) {
knopp's avatar
 
knopp committed
302 303 304
    // printf("Copying %d bytes for control elements\n",ce_ptr-mac_header_control_elements);
    memcpy((void*)mac_header_ptr,mac_header_control_elements,ce_ptr-mac_header_control_elements);
    mac_header_ptr+=(unsigned char)(ce_ptr-mac_header_control_elements);
305
  }
306

307 308 309 310 311 312
  //msg("After CEs %d\n",(uint8_t*)mac_header_ptr - mac_header);

  return((unsigned char*)mac_header_ptr - mac_header);

}

313 314 315 316 317 318 319
//------------------------------------------------------------------------------
void
set_ul_DAI(
  int module_idP,
  int UE_idP,
  int CC_idP,
  int frameP,
knopp's avatar
knopp committed
320 321
  int subframeP
) 
322
//------------------------------------------------------------------------------
323 324
{

325
  eNB_MAC_INST         *eNB      = RC.mac[module_idP];
knopp's avatar
 
knopp committed
326 327
  UE_list_t            *UE_list  = &eNB->UE_list;
  unsigned char         DAI;
knopp's avatar
knopp committed
328 329
  COMMON_channels_t    *cc       = &eNB->common_channels[CC_idP];
  if (cc->tdd_Config != NULL) {  //TDD
knopp's avatar
 
knopp committed
330
    DAI = (UE_list->UE_template[CC_idP][UE_idP].DAI-1)&3;
331
    LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframe %d: DAI %d for UE %d\n",module_idP,CC_idP,frameP,subframeP,DAI,UE_idP);
knopp's avatar
 
knopp committed
332
    // Save DAI for Format 0 DCI
333

knopp's avatar
knopp committed
334
    switch (cc->tdd_Config->subframeAssignment) {
knopp's avatar
 
knopp committed
335 336 337
    case 0:
      //      if ((subframeP==0)||(subframeP==1)||(subframeP==5)||(subframeP==6))
      break;
338

knopp's avatar
 
knopp committed
339 340 341
    case 1:
      switch (subframeP) {
      case 1:
342 343 344
        UE_list->UE_template[CC_idP][UE_idP].DAI_ul[7] = DAI;
        break;

knopp's avatar
 
knopp committed
345
      case 4:
346 347 348
        UE_list->UE_template[CC_idP][UE_idP].DAI_ul[8] = DAI;
        break;

knopp's avatar
 
knopp committed
349
      case 6:
350 351 352
        UE_list->UE_template[CC_idP][UE_idP].DAI_ul[2] = DAI;
        break;

knopp's avatar
 
knopp committed
353
      case 9:
354 355
        UE_list->UE_template[CC_idP][UE_idP].DAI_ul[3] = DAI;
        break;
knopp's avatar
 
knopp committed
356
      }
357

knopp's avatar
 
knopp committed
358 359
    case 2:
      //      if ((subframeP==3)||(subframeP==8))
360
      //  UE_list->UE_template[CC_idP][UE_idP].DAI_ul = DAI;
knopp's avatar
 
knopp committed
361
      break;
362

knopp's avatar
 
knopp committed
363
    case 3:
364

knopp's avatar
 
knopp committed
365 366 367 368
      //if ((subframeP==6)||(subframeP==8)||(subframeP==0)) {
      //  LOG_D(MAC,"schedule_ue_spec: setting UL DAI to %d for subframeP %d => %d\n",DAI,subframeP, ((subframeP+8)%10)>>1);
      //  UE_list->UE_template[CC_idP][UE_idP].DAI_ul[((subframeP+8)%10)>>1] = DAI;
      //}
369
      switch (subframeP) {
knopp's avatar
 
knopp committed
370 371 372
      case 5:
      case 6:
      case 1:
373 374 375
        UE_list->UE_template[CC_idP][UE_idP].DAI_ul[2] = DAI;
        break;

knopp's avatar
 
knopp committed
376 377
      case 7:
      case 8:
378 379 380
        UE_list->UE_template[CC_idP][UE_idP].DAI_ul[3] = DAI;
        break;

knopp's avatar
 
knopp committed
381 382
      case 9:
      case 0:
383 384 385
        UE_list->UE_template[CC_idP][UE_idP].DAI_ul[4] = DAI;
        break;

knopp's avatar
 
knopp committed
386
      default:
387
        break;
knopp's avatar
 
knopp committed
388
      }
389

knopp's avatar
 
knopp committed
390
      break;
391

knopp's avatar
 
knopp committed
392 393
    case 4:
      //      if ((subframeP==8)||(subframeP==9))
394
      //  UE_list->UE_template[CC_idP][UE_idP].DAI_ul = DAI;
knopp's avatar
 
knopp committed
395
      break;
396

knopp's avatar
 
knopp committed
397 398
    case 5:
      //      if (subframeP==8)
399
      //  UE_list->UE_template[CC_idP][UE_idP].DAI_ul = DAI;
knopp's avatar
 
knopp committed
400
      break;
401

knopp's avatar
 
knopp committed
402 403
    case 6:
      //      if ((subframeP==1)||(subframeP==4)||(subframeP==6)||(subframeP==9))
404
      //  UE_list->UE_template[CC_idP][UE_idP].DAI_ul = DAI;
knopp's avatar
 
knopp committed
405
      break;
406

knopp's avatar
 
knopp committed
407 408 409 410 411 412
    default:
      break;
    }
  }
}

413

414 415
// changes to pre-processor for eMTC

416 417 418
//------------------------------------------------------------------------------
void
schedule_ue_spec(
419 420 421
  module_id_t   module_idP,
  frame_t       frameP,
  sub_frame_t   subframeP,
422
  int*          mbsfn_flag
423 424
)
//------------------------------------------------------------------------------
425
{
knopp's avatar
 
knopp committed
426

427

428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
  uint8_t                        CC_id;
  int                            UE_id;
  unsigned char                  aggregation;
  mac_rlc_status_resp_t          rlc_status;
  unsigned char                  header_len_dcch=0, header_len_dcch_tmp=0; 
  unsigned char                  header_len_dtch=0, header_len_dtch_tmp=0, header_len_dtch_last=0; 
  unsigned char                  ta_len=0;
  unsigned char                  sdu_lcids[NB_RB_MAX],lcid,offset,num_sdus=0;
  uint16_t                       nb_rb,nb_rb_temp,nb_available_rb;
  uint16_t                       TBS,j,sdu_lengths[NB_RB_MAX],rnti,padding=0,post_padding=0;
  unsigned char                  dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES];
  unsigned char                  round             = 0;
  unsigned char                  harq_pid          = 0;
  eNB_UE_STATS                   *eNB_UE_stats     = NULL;
  uint16_t                       sdu_length_total = 0;

  eNB_MAC_INST                   *eNB      = RC.mac[module_idP];
  COMMON_channels_t              *cc       = eNB->common_channels;
  UE_list_t                      *UE_list  = &eNB->UE_list;
  int                            continue_flag=0;
  int32_t                        normalized_rx_power, target_rx_power;
  int32_t                        tpc=1;
  static int32_t                 tpc_accumulated=0;
  UE_sched_ctrl                  *ue_sched_ctl;
  int                            mcs;
  int                            i;
  int                            min_rb_unit[MAX_NUM_CCs];
  int                            N_RB_DL[MAX_NUM_CCs];
  int                            total_nb_available_rb[MAX_NUM_CCs];
  int                            N_RBG[MAX_NUM_CCs];
458
  nfapi_dl_config_request_body_t *dl_req;
459
  nfapi_dl_config_request_pdu_t  *dl_config_pdu;
460
  int                            tdd_sfa;
Cedric Roux's avatar
Cedric Roux committed
461
  int                            ta_update;
nikaeinn's avatar
nikaeinn committed
462

463
#if 0
464
  if (UE_list->head==-1) {
465
    return;
466
  }
467
#endif
468

469
  start_meas(&eNB->schedule_dlsch);
gauthier's avatar
gauthier committed
470
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_IN);
471

472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506

  // for TDD: check that we have to act here, otherwise return
  if (cc[0].tdd_Config) {
    tdd_sfa = cc[0].tdd_Config->subframeAssignment;
    switch (subframeP) {
    case 0:
      // always continue
       break;
    case 1:
      return;
	break;
    case 2:
      return;
      break;
    case 3:
      if ((tdd_sfa!=2) && (tdd_sfa!=5)) return;
      break;
    case 4:
      if ((tdd_sfa!=1)&&(tdd_sfa!=2)&&(tdd_sfa!=4)&&(tdd_sfa!=5)) return;
      break;
    case 5:
      break;
    case 6:
    case 7:
      if ((tdd_sfa!=1)&&(tdd_sfa!=2)&&(tdd_sfa!=4)&&(tdd_sfa!=5)) return;
      break;
    case 8:
      if ((tdd_sfa!=2)&&(tdd_sfa!=3)&&(tdd_sfa!=4)&&(tdd_sfa!=5)) return;
      break;
    case 9:
      if ((tdd_sfa!=1)&&(tdd_sfa!=3)&&(tdd_sfa!=4)&&(tdd_sfa!=6)) return;
      break;
   
    }
  }
Cedric Roux's avatar
Cedric Roux committed
507

508
  //weight = get_ue_weight(module_idP,UE_id);
509
  aggregation = 2; 
510
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
knopp's avatar
knopp committed
511
    N_RB_DL[CC_id] = to_prb(cc[CC_id].mib->message.dl_Bandwidth);
512
    min_rb_unit[CC_id]=get_min_rb_unit(module_idP,CC_id);
513
    // get number of PRBs less those used by common channels
knopp's avatar
knopp committed
514 515 516
    total_nb_available_rb[CC_id] = N_RB_DL[CC_id];
    for (i=0;i<N_RB_DL[CC_id];i++)
      if (cc[CC_id].vrb_map[i]!=0)
517 518
	total_nb_available_rb[CC_id]--;

knopp's avatar
knopp committed
519
    N_RBG[CC_id] = to_rbg(cc[CC_id].mib->message.dl_Bandwidth);
520

521
    // store the global enb stats:
knopp's avatar
knopp committed
522 523
    eNB->eNB_stats[CC_id].num_dlactive_UEs      =  UE_list->num_UEs;
    eNB->eNB_stats[CC_id].available_prbs        =  total_nb_available_rb[CC_id];
524
    eNB->eNB_stats[CC_id].total_available_prbs +=  total_nb_available_rb[CC_id];
knopp's avatar
knopp committed
525 526
    eNB->eNB_stats[CC_id].dlsch_bytes_tx        = 0;
    eNB->eNB_stats[CC_id].dlsch_pdus_tx         = 0;
knopp's avatar
 
knopp committed
527
  }
528

529
  /// CALLING Pre_Processor for downlink scheduling (Returns estimation of RBs required by each UE and the allocation on sub-band)
530

gauthier's avatar
gauthier committed
531
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_IN);
knopp's avatar
 
knopp committed
532
  start_meas(&eNB->schedule_dlsch_preprocessor);
533
  dlsch_scheduler_pre_processor(module_idP,
534 535 536 537
                                frameP,
                                subframeP,
                                N_RBG,
                                mbsfn_flag);
knopp's avatar
 
knopp committed
538
  stop_meas(&eNB->schedule_dlsch_preprocessor);
gauthier's avatar
gauthier committed
539
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_OUT);
knopp's avatar
 
knopp committed
540

541
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
542
    //LOG_D(MAC, "doing schedule_ue_spec for CC_id %d\n",CC_id);
543

544 545
    dl_req        = &eNB->DL_req[CC_id].dl_config_request_body;

knopp's avatar
 
knopp committed
546 547
    if (mbsfn_flag[CC_id]>0)
      continue;
548 549

    for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) {
550
      continue_flag=0; // reset the flag to allow allocation for the remaining UEs
knopp's avatar
 
knopp committed
551
      rnti = UE_RNTI(module_idP,UE_id);
552
      eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id];
553
      ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id];
554

555
      //LOG_D(MAC,"%s() rnti:%x, eNB_UE_stats:%p, ue_sched_ctl:%p tmode:%d\n", __FUNCTION__, rnti, eNB_UE_stats, ue_sched_ctl, get_tmode(module_idP,CC_id,UE_id));
556

557
      if (rnti==NOT_A_RNTI) {
558 559
        LOG_D(MAC,"Cannot find rnti for UE_id %d (num_UEs %d)\n",UE_id,UE_list->num_UEs);
        continue_flag=1;
560
      }
561

562
      if (eNB_UE_stats==NULL) {
563 564
        LOG_D(MAC,"[eNB] Cannot find eNB_UE_stats\n");
        continue_flag=1;
565
      }
566 567

      if (continue_flag != 1){
568
        switch(get_tmode(module_idP,CC_id,UE_id)){
569 570 571 572
        case 1:
        case 2:
        case 7:
	  aggregation = get_aggregation(get_bw_index(module_idP,CC_id), 
Cedric Roux's avatar
Cedric Roux committed
573
					ue_sched_ctl->dl_cqi[CC_id],
574
					format1);
575 576 577
	  break;
        case 3:
	  aggregation = get_aggregation(get_bw_index(module_idP,CC_id), 
Cedric Roux's avatar
Cedric Roux committed
578
					ue_sched_ctl->dl_cqi[CC_id],
579
					format2A);
580 581
	  break;
        default:
582
	  LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id));
583 584 585 586
	  aggregation = 2;
        }
      } /* if (continue_flag != 1 */

587
      if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) ||  // no RBs allocated 
588
	  CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,aggregation,rnti)
589
	  ) {
590
        //LOG_D(MAC,"[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", module_idP, frameP, UE_id, CC_id);
591
        continue_flag=1; //to next user (there might be rbs availiable for other UEs in TM5
592
      }
593

knopp's avatar
knopp committed
594
      if (cc[CC_id].tdd_Config != NULL) { //TDD
595 596 597
        set_ue_dai (subframeP,
                    UE_id,
                    CC_id,
knopp's avatar
knopp committed
598
		    cc[CC_id].tdd_Config->subframeAssignment,
599 600
                    UE_list);
        // update UL DAI after DLSCH scheduling
knopp's avatar
knopp committed
601
        set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP);
knopp's avatar
 
knopp committed
602 603
      }

604
      if (continue_flag == 1 ) {
605
        //LOG_D(MAC,"[eNB %d] Frame %d : UE %d on CC_id %d: continue flag - add_ue_dlsch_info\n", module_idP, frameP, UE_id, CC_id);
606 607 608 609 610 611
        add_ue_dlsch_info(module_idP,
                          CC_id,
                          UE_id,
                          subframeP,
                          S_DL_NONE);
        continue;
nikaeinn's avatar
nikaeinn committed
612
      }
613

614 615
#warning RK->CR This old API call has to be revisited for FAPI, or logic must be changed
#if 0
Cedric Roux's avatar
Cedric Roux committed
616 617 618 619 620 621 622 623 624 625 626
      /* add "fake" DCI to have CCE_allocation_infeasible work properly for next allocations */
      /* if we don't add it, next allocations may succeed but overall allocations may fail */
      /* will be removed at the end of this function */
      add_ue_spec_dci(&eNB->common_channels[CC_id].DCI_pdu,
                      &(char[]){0},
                      rnti,
                      1,
                      aggregation,
                      1,
                      format1,
                      0);
627
#endif
Cedric Roux's avatar
Cedric Roux committed
628

629
      nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id];
630 631 632 633 634 635

      if (cc->tdd_Config) harq_pid = ((frameP*10)+subframeP)%10;
      else harq_pid = ((frameP*10)+subframeP)&7;

      round = ue_sched_ctl->round[CC_id][harq_pid];

636
      UE_list->eNB_UE_stats[CC_id][UE_id].crnti= rnti;
637
      UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status=mac_eNB_get_rrc_status(module_idP,rnti);
638
      UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid; 
639
      UE_list->eNB_UE_stats[CC_id][UE_id].harq_round = round;
640

641 642 643

      if (UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status < RRC_CONNECTED) continue;

644 645
      sdu_length_total=0;
      num_sdus=0;
646 647

      /*
648 649
      DevCheck(((eNB_UE_stats->dl_cqi < MIN_CQI_VALUE) || (eNB_UE_stats->dl_cqi > MAX_CQI_VALUE)),
      eNB_UE_stats->dl_cqi, MIN_CQI_VALUE, MAX_CQI_VALUE);
650
      */
David Price's avatar
David Price committed
651
      eNB_UE_stats->dlsch_mcs1 = 10;//cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]];
652

653

654
      // store stats
Cedric Roux's avatar
Cedric Roux committed
655
      //UE_list->eNB_UE_stats[CC_id][UE_id].dl_cqi= eNB_UE_stats->dl_cqi;
656

657
      // initializing the rb allocation indicator for each UE
knopp's avatar
knopp committed
658
      for(j=0; j<N_RBG[CC_id]; j++) {
659
        UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = 0;
660 661
      }

662
      LOG_D(MAC,"[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, rrc %d)\n",
663
            module_idP, frameP, UE_id,CC_id,rnti,harq_pid, round,nb_available_rb,
Cedric Roux's avatar
Cedric Roux committed
664
            ue_sched_ctl->dl_cqi[CC_id], eNB_UE_stats->dlsch_mcs1,
665
	    UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status);
666 667 668



669 670
      /* process retransmission  */

671
      if (round != 8) {
672

673 674
        // get freq_allocation
        nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid];
675
	TBS = get_TBS_DL(UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid],nb_rb);
676 677

        if (nb_rb <= nb_available_rb) {
678
          if (cc[CC_id].tdd_Config != NULL) {
679 680 681 682
            UE_list->UE_template[CC_id][UE_id].DAI++;
            update_ul_dci(module_idP,CC_id,rnti,UE_list->UE_template[CC_id][UE_id].DAI);
            LOG_D(MAC,"DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", CC_id,subframeP,UE_id,UE_list->UE_template[CC_id][UE_id].DAI);
          }
683

684
          if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) {
knopp's avatar
knopp committed
685
            for(j=0; j<N_RBG[CC_id]; j++) { // for indicating the rballoc for each sub-band
686
              UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j];
687
            }
688 689 690 691
          } else {
            nb_rb_temp = nb_rb;
            j = 0;

knopp's avatar
knopp committed
692
            while((nb_rb_temp > 0) && (j<N_RBG[CC_id])) {
693
              if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) {
Cedric Roux's avatar
Cedric Roux committed
694
                if (UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]) printf("WARN: rballoc_subband not free for retrans?\n");
695
                UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j];
696

knopp's avatar
knopp committed
697 698 699
                if((j == N_RBG[CC_id]-1) &&
                    ((N_RB_DL[CC_id] == 25)||
                     (N_RB_DL[CC_id] == 50))) {
700
                  nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id]+1;
701
                } else {
702
                  nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id];
703
                }
704 705 706 707 708 709 710
              }

              j = j+1;
            }
          }

          nb_available_rb -= nb_rb;
knopp's avatar
knopp committed
711 712 713
	  /*
          eNB->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb;
          eNB->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id];
714

knopp's avatar
knopp committed
715 716
          for(j=0; j<N_RBG[CC_id]; j++) {
            eNB->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j];
717
          }
knopp's avatar
knopp committed
718
	  */
719

720
          switch (get_tmode(module_idP,CC_id,UE_id)) {
721 722
          case 1:
          case 2:
Xiwen JIANG's avatar
Xiwen JIANG committed
723
          case 7:
724
          default:
725
	    dl_config_pdu                                                         = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; 
726 727
	    memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t));
	    dl_config_pdu->pdu_type                                               = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; 
728
	    dl_config_pdu->pdu_size                                               = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu));
729
	    dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag                      = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG;
730
	    dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format                  = NFAPI_DL_DCI_FORMAT_1;
Cedric Roux's avatar
Cedric Roux committed
731
	    dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level           = get_aggregation(get_bw_index(module_idP,CC_id),ue_sched_ctl->dl_cqi[CC_id],format1);
732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753
	    dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti                        = rnti;
	    dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type                   = 1;    // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications
	    dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power          = 6000; // equal to RS power

	    dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process                = harq_pid;
	    dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc                         = 1; // dont adjust power when retransmitting
	    dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1        = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];
	    dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1                       = UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid];
	    dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1        = round&3;

	    if (cc[CC_id].tdd_Config != NULL) { //TDD
	      dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3;
	      LOG_D(MAC,"[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, dai %d, mcs %d\n",
		    module_idP,CC_id,harq_pid,round,
		    (UE_list->UE_template[CC_id][UE_id].DAI-1),
		    UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]);
	    } else {
	      LOG_D(MAC,"[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, mcs %d\n",
		    module_idP,CC_id,harq_pid,round,
		    UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]);
	      
	    }
754
	    if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,
755 756
					   dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,
					   rnti)) {
757 758
	      dl_req->number_dci++;
	      dl_req->number_pdu++;
759
	      dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
760

761 762 763
              eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP;
              eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST;

764 765
	      fill_nfapi_dlsch_config(eNB,dl_req,
				      TBS,
766
				      -1            /* retransmission, no pdu_index */,
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788
				      rnti,
				      0, // type 0 allocation from 7.1.6 in 36.213
				      0, // virtual_resource_block_assignment_flag, unused here
				      0,          // resource_block_coding, to be filled in later
				      getQm(UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]),
				      round&3   , // redundancy version
				      1, // transport blocks
				      0, // transport block to codeword swap flag
				      cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme
				      1, // number of layers
				      1, // number of subbands
			     //			     uint8_t codebook_index,
				      4, // UE category capacity
				      UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, 
				      0, // delta_power_offset for TM5
				      0, // ngap
				      0, // nprb
				      cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode
				      0, //number of PRBs treated as one subband, not used here
				      0 // number of beamforming vectors, not used here
				      );

knopp's avatar
knopp committed
789
	      LOG_D(MAC,"Filled NFAPI configuration for DCI/DLSCH %d, retransmission round %d\n",eNB->pdu_index[CC_id],round);
790
             
791

792 793
	      program_dlsch_acknak(module_idP,CC_id,UE_id,frameP,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx);
	      // No TX request for retransmission (check if null request for FAPI)
794 795
	    }
	    else {
796 797
	      LOG_W(MAC,"Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d\%x, infeasible CCE allocation\n",
		    frameP,subframeP,UE_id,rnti);
798 799
	    }
	  }
800 801


802 803 804 805 806 807 808 809 810 811 812 813 814
	  add_ue_dlsch_info(module_idP,
			    CC_id,
			    UE_id,
			    subframeP,
			    S_DL_SCHEDULED);
	  
	  //eNB_UE_stats->dlsch_trials[round]++;
	  UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission+=1;
	  UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx=nb_rb;
	  UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_retx+=nb_rb;
	  UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1=eNB_UE_stats->dlsch_mcs1;
	  UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2=eNB_UE_stats->dlsch_mcs1;
	} else {
815 816
          LOG_D(MAC,"[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n",
                module_idP, frameP, CC_id, UE_id);
817 818
        }
      } else { /* This is a potentially new SDU opportunity */
819
	
820 821 822
        rlc_status.bytes_in_buffer = 0;
        // Now check RLC information to compute number of required RBs
        // get maximum TBS size for RLC request
823
        TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_available_rb);
824 825 826
        // check first for RLC data on DCCH
        // add the length for  all the control elements (timing adv, drx, etc) : header + payload

Cedric Roux's avatar
Cedric Roux committed
827 828 829 830 831 832 833 834 835 836 837 838
        if (ue_sched_ctl->ta_timer == 0) {
          ta_update = ue_sched_ctl->ta_update;
          /* if we send TA then set timer to not send it for a while */
          if (ta_update != 31)
            ue_sched_ctl->ta_timer = 20;
          /* reset ta_update */
          ue_sched_ctl->ta_update = 31;
        } else {
          ta_update = 31;
        }

        ta_len = (ta_update != 31) ? 2 : 0;
839 840 841 842 843 844

        header_len_dcch = 2; // 2 bytes DCCH SDU subheader

        if ( TBS-ta_len-header_len_dcch > 0 ) {
          rlc_status = mac_rlc_status_ind(
                         module_idP,
845
                         rnti,
846
			 module_idP,
847
                         frameP,
848
			 subframeP,
849 850 851
                         ENB_FLAG_YES,
                         MBMS_FLAG_NO,
                         DCCH,
852 853 854 855 856
                         (TBS-ta_len-header_len_dcch) // transport block set size
#ifdef Rel14
                          ,0, 0
#endif
                          );
857 858 859 860

          sdu_lengths[0]=0;

          if (rlc_status.bytes_in_buffer > 0) {  // There is DCCH to transmit
861 862
            LOG_D(MAC,"[eNB %d] Frame %d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n",
                  module_idP,frameP,CC_id,TBS-header_len_dcch);
knopp's avatar
knopp committed
863 864 865 866 867 868 869 870
            sdu_lengths[0] = mac_rlc_data_req(
					      module_idP,
					      rnti,
					      module_idP,
					      frameP,
					      ENB_FLAG_YES,
					      MBMS_FLAG_NO,
					      DCCH,
871
					      TBS, //not used
872 873 874 875 876 877
					      (char *)&dlsch_buffer[0]
#ifdef Rel14
                     ,0,
                      0
#endif
                     );
878

Cedric Roux's avatar
Cedric Roux committed
879 880 881
            T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP),
              T_INT(harq_pid), T_INT(DCCH), T_INT(sdu_lengths[0]));

882
            LOG_D(MAC,"[eNB %d][DCCH] CC_id %d Got %d bytes from RLC\n",module_idP,CC_id,sdu_lengths[0]);
883 884 885 886 887
            sdu_length_total = sdu_lengths[0];
            sdu_lcids[0] = DCCH;
            UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH]+=1;
            UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH]+=sdu_lengths[0];
            num_sdus = 1;
888
#ifdef DEBUG_eNB_SCHEDULER
889
            LOG_T(MAC,"[eNB %d][DCCH] CC_id %d Got %d bytes :",module_idP,CC_id,sdu_lengths[0]);
890

891
            for (j=0; j<sdu_lengths[0]; j++) {
892
              LOG_T(MAC,"%x ",dlsch_buffer[j]);
893
            }
894 895 896 897 898 899 900 901

            LOG_T(MAC,"\n");
#endif
          } else {
            header_len_dcch = 0;
            sdu_length_total = 0;
          }
        }
knopp's avatar
knopp committed
902
	
903 904 905 906
        // check for DCCH1 and update header information (assume 2 byte sub-header)
        if (TBS-ta_len-header_len_dcch-sdu_length_total > 0 ) {
          rlc_status = mac_rlc_status_ind(
                         module_idP,
907
                         rnti,
908
			 module_idP,
909
                         frameP,
910
						 subframeP,
911 912 913
                         ENB_FLAG_YES,
                         MBMS_FLAG_NO,
                         DCCH+1,
914 915 916 917 918
                         (TBS-ta_len-header_len_dcch-sdu_length_total) // transport block set size less allocations for timing advance and
#ifdef Rel14
                          ,0, 0
#endif
                          );
919
          // DCCH SDU
knopp's avatar
knopp committed
920
	  sdu_lengths[num_sdus] = 0;
921 922

          if (rlc_status.bytes_in_buffer > 0) {
knopp's avatar
knopp committed
923
            LOG_D(MAC,"[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n",
924
                  module_idP,frameP,CC_id,TBS-header_len_dcch-sdu_length_total);
925 926
            sdu_lengths[num_sdus] += mac_rlc_data_req(
                                       module_idP,