eNB_scheduler.c 17.6 KB
Newer Older
1
/*******************************************************************************
nikaeinn's avatar
nikaeinn committed
2 3
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom
4

nikaeinn's avatar
nikaeinn committed
5 6 7 8
    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
9 10


nikaeinn's avatar
nikaeinn committed
11 12 13 14
    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
15

nikaeinn's avatar
nikaeinn committed
16 17 18 19
    You should have received a copy of the GNU General Public License
    along with OpenAirInterface.The full GNU General Public License is
    included in this distribution in the file called "COPYING". If not,
    see <http://www.gnu.org/licenses/>.
20 21

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

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

nikaeinn's avatar
nikaeinn committed
28
*******************************************************************************/
29
/*! \file eNB_scheduler.c
nikaeinn's avatar
nikaeinn committed
30
 * \brief eNB scheduler top level function operates on per subframe basis
31 32
 * \author  Navid Nikaein and Raymond Knopp
 * \date 2010 - 2014
33
 * \email: navid.nikaein@eurecom.fr
34 35
 * \version 0.5
 * @ingroup _mac
36

37
 */
38

39
#include "assertions.h"
40 41 42 43 44 45 46 47
#include "PHY/defs.h"
#include "PHY/extern.h"

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

#include "LAYER2/MAC/defs.h"
#include "LAYER2/MAC/extern.h"
gauthier's avatar
gauthier committed
48

49 50 51 52 53 54
#include "LAYER2/MAC/proto.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"
gauthier's avatar
gauthier committed
55

56 57
#include "RRC/LITE/extern.h"
#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
gauthier's avatar
gauthier committed
58

59 60
//#include "LAYER2/MAC/pre_processor.c"
#include "pdcp.h"
61

62 63
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
64 65
#endif

66 67 68 69
#define ENABLE_MAC_PAYLOAD_DEBUG
#define DEBUG_eNB_SCHEDULER 1
//#define DEBUG_HEADER_PARSING 1
//#define DEBUG_PACKET_TRACE 1
gauthier's avatar
gauthier committed
70

71 72 73 74 75
/*
  #ifndef USER_MODE
  #define msg debug_msg
  #endif
 */
gauthier's avatar
gauthier committed
76 77 78



79

80
void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, frame_t frameP, sub_frame_t subframeP) {//, int calibration_flag) {
81

82 83 84 85
  unsigned int nprb[MAX_NUM_CCs];
  unsigned int nCCE[MAX_NUM_CCs];
  int mbsfn_status[MAX_NUM_CCs];
  uint32_t RBalloc[MAX_NUM_CCs];
86
  protocol_ctxt_t   ctxt;
87
#ifdef EXMIMO
88
  int ret;
89
#endif
90
#if defined(ENABLE_ITTI)
91 92 93 94
  MessageDef   *msg_p;
  const char   *msg_name;
  instance_t    instance;
  int           result;
95
#endif
96
  DCI_PDU *DCI_pdu[MAX_NUM_CCs];
97
  int CC_id,i,next_i;
98
  UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list;
99

100
  LOG_D(MAC,"[eNB %d] Frame %d, Subframe %d, entering MAC scheduler (UE_list->head %d)\n",module_idP, frameP, subframeP,UE_list->head);
101

102 103
  start_meas(&eNB_mac_inst[module_idP].eNB_scheduler);
  vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN);
104

105 106 107 108 109 110 111
  for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
    DCI_pdu[CC_id] = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu;
    nCCE[CC_id]=0;
    nprb[CC_id]=0;
    RBalloc[CC_id]=0;
    mbsfn_status[CC_id]=0;
  }
112
  // refresh UE list based on UEs dropped by PHY in previous subframe
113 114
  for (i=UE_list->head;i>=0;i=UE_list->next[i]) {
    LOG_D(MAC,"UE %d: rnti %x (%p)\n",i,UE_RNTI(module_idP,i),mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i)));
115
    if (mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i))==NULL)
116
      mac_remove_ue(module_idP,i,frameP);
117
  }
118 119
#if defined(ENABLE_ITTI)
  do {
gauthier's avatar
gauthier committed
120 121
      // Checks if a message has been sent to MAC sub-task
      itti_poll_msg (TASK_MAC_ENB, &msg_p);
122

gauthier's avatar
gauthier committed
123 124 125
      if (msg_p != NULL) {
          msg_name = ITTI_MSG_NAME (msg_p);
          instance = ITTI_MSG_INSTANCE (msg_p);
126

gauthier's avatar
gauthier committed
127 128 129 130
          switch (ITTI_MSG_ID(msg_p)) {
          case MESSAGE_TEST:
            LOG_D(MAC, "Received %s\n", ITTI_MSG_NAME(msg_p));
            break;
131

gauthier's avatar
gauthier committed
132 133
          case RRC_MAC_BCCH_DATA_REQ:
            LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n",
134
                msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
135
                RRC_MAC_BCCH_DATA_REQ (msg_p).frame, RRC_MAC_BCCH_DATA_REQ (msg_p).enb_index);
136

gauthier's avatar
gauthier committed
137 138
            // TODO process BCCH data req.
            break;
139

gauthier's avatar
gauthier committed
140 141
          case RRC_MAC_CCCH_DATA_REQ:
            LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n",
142
                msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
143
                RRC_MAC_CCCH_DATA_REQ (msg_p).frame, RRC_MAC_CCCH_DATA_REQ (msg_p).enb_index);
144

gauthier's avatar
gauthier committed
145 146
            // TODO process CCCH data req.
            break;
147 148

#ifdef Rel10
gauthier's avatar
gauthier committed
149 150
          case RRC_MAC_MCCH_DATA_REQ:
            LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d, mbsfn_sync_area %d\n",
151
                msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
152
                RRC_MAC_MCCH_DATA_REQ (msg_p).frame, RRC_MAC_MCCH_DATA_REQ (msg_p).enb_index, RRC_MAC_MCCH_DATA_REQ (msg_p).mbsfn_sync_area);
153

gauthier's avatar
gauthier committed
154 155
            // TODO process MCCH data req.
            break;
156 157
#endif

gauthier's avatar
gauthier committed
158 159 160 161
          default:
            LOG_E(MAC, "Received unexpected message %s\n", msg_name);
            break;
          }
162

gauthier's avatar
gauthier committed
163 164 165
          result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
          AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
      }
166 167 168
  } while(msg_p != NULL);
#endif

gauthier's avatar
gauthier committed
169
  // clear DCI and BCCH contents before scheduling
170 171 172 173 174
  for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
    DCI_pdu[CC_id]->Num_common_dci  = 0;
    DCI_pdu[CC_id]->Num_ue_spec_dci = 0;
    eNB_mac_inst[module_idP].common_channels[CC_id].bcch_active = 0;
    
175
#ifdef Rel10
176
    eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active =0;
177
#endif
178 179 180 181
    
    eNB_mac_inst[module_idP].frame    = frameP;
    eNB_mac_inst[module_idP].subframe = subframeP;
  }
182

gauthier's avatar
gauthier committed
183
  //if (subframeP%5 == 0)
184
  //#ifdef EXMIMO
185 186 187 188 189
  ctxt.enb_module_id = module_idP;
  ctxt.ue_module_id  = 0;
  ctxt.frame         = frameP;
  ctxt.enb_flag      = ENB_FLAG_YES;
  pdcp_run(&ctxt);
190
  //#endif
191

192
  // check HO
gauthier's avatar
gauthier committed
193
  rrc_rx_tx(module_idP,
194 195 196
            frameP,
            1,
            module_idP,
197
            CC_id);
198 199

#ifdef Rel10
200
  for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
201 202 203 204
    if (eNB_mac_inst[module_idP].common_channels[CC_id].MBMS_flag >0) {
      start_meas(&eNB_mac_inst[module_idP].schedule_mch);
      mbsfn_status[CC_id] = schedule_MBMS(module_idP,CC_id,frameP,subframeP);
      stop_meas(&eNB_mac_inst[module_idP].schedule_mch);
205
    }
206 207
  }
#endif
208
  // refresh UE list based on UEs dropped by PHY in previous subframe
209
  /* 
210 211 212
  i=UE_list->head;
  while (i>=0) {
    next_i = UE_list->next[i];
213
    LOG_T(MAC,"UE %d : rnti %x, stats %p\n",i,UE_RNTI(module_idP,i),mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i)));
214
    if (mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i))==NULL) {
215
      mac_remove_ue(module_idP,i,frameP);
216 217 218
    }
    i=next_i;
  }
219
  */
220

gauthier's avatar
gauthier committed
221
  switch (subframeP) {
222 223
  case 0:
    // FDD/TDD Schedule Downlink RA transmissions (RA response, Msg4 Contention resolution)
gauthier's avatar
gauthier committed
224
    // Schedule ULSCH for FDD or subframeP 4 (TDD config 0,3,6)
225
    // Schedule Normal DLSCH
gauthier's avatar
gauthier committed
226

227
    schedule_RA(module_idP,frameP,subframeP,2,nprb,nCCE);
228 229

    if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
230
      schedule_ulsch(module_idP,frameP,cooperation_flag,0,4,nCCE);//,calibration_flag);
231 232
    }
    else if  ((mac_xface->lte_frame_parms->tdd_config == TDD) || //TDD
Florian Kaltenberger's avatar
Florian Kaltenberger committed
233 234
	      (mac_xface->lte_frame_parms->tdd_config == 3) ||
	      (mac_xface->lte_frame_parms->tdd_config == 6)) {
235
      //schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4,nCCE);//,calibration_flag);
Florian Kaltenberger's avatar
Florian Kaltenberger committed
236 237 238
    }
    
    // schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
239

Florian Kaltenberger's avatar
Florian Kaltenberger committed
240
    fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);
241 242 243
    break;

  case 1:
gauthier's avatar
gauthier committed
244
    // TDD, schedule UL for subframeP 7 (TDD config 0,1) / subframeP 8 (TDD Config 6)
245 246
    // FDD, schedule normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
gauthier's avatar
gauthier committed
247 248 249
        switch (mac_xface->lte_frame_parms->tdd_config) {
        case 0:
        case 1:
250
          schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7,nCCE);
gauthier's avatar
gauthier committed
251 252 253
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
          break;
        case 6:
254
          schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8,nCCE);
gauthier's avatar
gauthier committed
255 256 257 258 259
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
          break;
        default:
          break;
        }
260 261
    }
    else {  //FDD
262 263
      schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
264
      schedule_ulsch(module_idP,frameP,cooperation_flag,1,5,nCCE);
265
	
266 267
    }
    break;
268 269

  case 2:
gauthier's avatar
gauthier committed
270
    // TDD, nothing
271 272
    // FDD, normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
273 274
      schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
275
      schedule_ulsch(module_idP,frameP,cooperation_flag,2,6,nCCE);
276
    
277 278 279 280
    }
    break;

  case 3:
gauthier's avatar
gauthier committed
281
    // TDD Config 2, ULSCH for subframeP 7
282 283 284
    // TDD Config 2/5 normal DLSCH
    // FDD, normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) {
gauthier's avatar
gauthier committed
285 286
        switch (mac_xface->lte_frame_parms->tdd_config) {
        case 2:
287
          schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7,nCCE);
288
          // no break here!
gauthier's avatar
gauthier committed
289
        case 5:
290
          schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
291 292 293 294 295
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
          break;
        default:
          break;
        }
296 297
    }
    else { //FDD
298 299
      //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
      //fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
300
      schedule_ulsch(module_idP,frameP,cooperation_flag,3,7,nCCE);
301

302 303
    }
    break;
304 305

  case 4:
gauthier's avatar
gauthier committed
306
    // TDD Config 1, ULSCH for subframeP 8
307 308 309
    // TDD Config 1/2/4/5 DLSCH
    // FDD UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == 1) { // TDD
gauthier's avatar
gauthier committed
310 311
        switch (mac_xface->lte_frame_parms->tdd_config) {
        case 1:
312 313
          //        schedule_RA(module_idP,frameP,subframeP,nprb,nCCE);
          schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8,nCCE);
314
          // no break here!
gauthier's avatar
gauthier committed
315
        case 2:
316
          // no break here!
gauthier's avatar
gauthier committed
317
        case 4:
318
          // no break here!
gauthier's avatar
gauthier committed
319
        case 5:
320
          schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
321 322 323 324 325
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);
          break;
        default:
          break;
        }
326 327
    }
    else {
gauthier's avatar
gauthier committed
328
        if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
329 330 331 332
	  schedule_RA(module_idP,frameP, subframeP, 0, nprb, nCCE);
            //	schedule_ulsch(module_idP, frameP, cooperation_flag, 4, 8, nCCE);
            //schedule_ue_spec(module_idP, frameP, subframeP, nprb, nCCE, mbsfn_status);
	  fill_DLSCH_dci(module_idP, frameP, subframeP, RBalloc, 1, mbsfn_status);
knopp's avatar
knopp committed
333

gauthier's avatar
gauthier committed
334
        }
335 336 337 338 339 340 341 342
    }
    break;

  case 5:
    // TDD/FDD Schedule SI
    // TDD Config 0,6 ULSCH for subframes 9,3 resp.
    // TDD normal DLSCH
    // FDD normal UL/DLSCH
343 344
    schedule_SI(module_idP,frameP,nprb,nCCE);
    //schedule_RA(module_idP,frameP,subframeP,5,nprb,nCCE);
345
    if ((mac_xface->lte_frame_parms->frame_type == FDD) ) {
346 347
        //      schedule_RA(module_idP,frameP,subframeP,1,nprb,nCCE);
        //      schedule_ulsch(module_idP,frameP,cooperation_flag,5,9,nCCE);
gauthier's avatar
gauthier committed
348
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
349 350 351

    }
    else if ((mac_xface->lte_frame_parms->tdd_config == 0) || // TDD Config 0
gauthier's avatar
gauthier committed
352
        (mac_xface->lte_frame_parms->tdd_config == 6)) { // TDD Config 6
353
        //schedule_ulsch(module_idP,cooperation_flag,subframeP,nCCE);
gauthier's avatar
gauthier committed
354
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
355 356
    }
    else {
357
        //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
358
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
359 360 361 362 363 364 365 366
    }
    break;

  case 6:
    // TDD Config 0,1,6 ULSCH for subframes 2,3
    // TDD Config 3,4,5 Normal DLSCH
    // FDD normal ULSCH/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
gauthier's avatar
gauthier committed
367 368 369 370
        switch (mac_xface->lte_frame_parms->tdd_config) {
        case 0:
          break;
        case 1:
371 372
          schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2,nCCE);
          //	schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
373 374 375
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
          break;
        case 6:
376 377
          schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,nCCE);
          //	schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
378 379 380
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
          break;
        case 5:
381 382
          schedule_RA(module_idP,frameP,subframeP,2,nprb,nCCE);
          schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
383 384 385 386
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);
          break;
        case 3:
        case 4:
387
          schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
388 389 390 391 392 393
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
          break;

        default:
          break;
        }
394 395
    }
    else {  //FDD
396 397
        //      schedule_ulsch(module_idP,frameP,cooperation_flag,6,0,nCCE);
        schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
398
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
399 400
    }
    break;
gauthier's avatar
gauthier committed
401

402 403 404 405
  case 7:
    // TDD Config 3,4,5 Normal DLSCH
    // FDD Normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
gauthier's avatar
gauthier committed
406 407 408
        switch (mac_xface->lte_frame_parms->tdd_config) {
        case 3:
        case 4:
409 410
          //	  schedule_RA(module_idP,frameP,subframeP,3,nprb,nCCE);  // 3 = Msg3 subframeP, not
          schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
411 412 413
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); //1,mbsfn_status);
          break;
        case 5:
414
          schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
415 416 417 418 419
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
          break;
        default:
          break;
        }
420
    }
421
    else {  //FDD
422 423 424
      //schedule_ulsch(module_idP,frameP,cooperation_flag,7,1,nCCE);
      schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
425 426 427 428
    }
    break;

  case 8:
gauthier's avatar
gauthier committed
429
    // TDD Config 2,3,4,5 ULSCH for subframeP 2
430 431 432
    //
    // FDD Normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
gauthier's avatar
gauthier committed
433 434 435 436 437 438
        switch (mac_xface->lte_frame_parms->tdd_config) {
        case 2:
        case 3:
        case 4:
        case 5:

439 440 441
          //	schedule_RA(module_idP,subframeP,nprb,nCCE);
          schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2,nCCE);
          schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
442 443 444 445 446
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
          break;
        default:
          break;
        }
447 448
    }
    else {  //FDD
449 450 451
      //schedule_ulsch(module_idP,frameP,cooperation_flag,8,2,nCCE);
      schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
452 453 454 455 456 457
    }
    break;

  case 9:
    // TDD Config 1,3,4,6 ULSCH for subframes 3,3,3,4
    if (mac_xface->lte_frame_parms->frame_type == TDD) {
gauthier's avatar
gauthier committed
458 459
        switch (mac_xface->lte_frame_parms->tdd_config) {
        case 1:
460 461 462
          schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,nCCE);
          schedule_RA(module_idP,frameP,subframeP,7,nprb,nCCE);  // 7 = Msg3 subframeP, not
          schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
463 464 465 466
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);
          break;
        case 3:
        case 4:
467 468
          schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,nCCE);
          schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
469 470 471
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
          break;
        case 6:
472 473 474
          schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4,nCCE);
          //schedule_RA(module_idP,frameP,subframeP,nprb,nCCE);
          schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
475 476 477 478
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
          break;
        case 2:
        case 5:
479 480
          //schedule_RA(module_idP,frameP,subframeP,nprb,nCCE);
          schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
481 482 483 484 485
          fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
          break;
        default:
          break;
        }
486 487
    }
    else {  //FDD
488
      //     schedule_ulsch(module_idP,frameP,cooperation_flag,9,3,nCCE);
489
        schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
gauthier's avatar
gauthier committed
490
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
491 492
    }
    break;
gauthier's avatar
gauthier committed
493

494
  }
495

496 497 498
  for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++)
    DCI_pdu[CC_id]->nCCE = nCCE[CC_id];
  LOG_D(MAC,"frameP %d, subframeP %d nCCE %d\n",frameP,subframeP,nCCE[0]);
499

500
  stop_meas(&eNB_mac_inst[module_idP].eNB_scheduler);
501 502
  vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT);
 
503
}
504 505 506