eNB_scheduler.c 35 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
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
24
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr
nikaeinn's avatar
nikaeinn committed
25

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
//Agent-related headers
nikaeinn's avatar
nikaeinn committed
63
64
65
#include "enb_agent_extern.h"
#include "enb_agent_mac.h"
#include "enb_agent_mac_proto.h"
66

67
68
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
69
70
#endif

71
72
#define ENABLE_MAC_PAYLOAD_DEBUG
#define DEBUG_eNB_SCHEDULER 1
73
#define ENABLE_ENB_AGENT_DL_SCHEDULER
74
//#define DISABLE_SF_TRIGGER
75

76
77
//#define DEBUG_HEADER_PARSING 1
//#define DEBUG_PACKET_TRACE 1
gauthier's avatar
gauthier committed
78

79
80
81
82
83
/*
  #ifndef USER_MODE
  #define msg debug_msg
  #endif
 */
gauthier's avatar
gauthier committed
84
85
86



87

88
89
90



91
92
void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, frame_t frameP, sub_frame_t subframeP)  //, int calibration_flag) {
{
93

knopp's avatar
   
knopp committed
94
  int mbsfn_status[MAX_NUM_CCs];
95
  protocol_ctxt_t   ctxt;
96
#ifdef EXMIMO
97
  int ret;
98
#endif
99
#if defined(ENABLE_ITTI)
100
101
102
103
  MessageDef   *msg_p;
  const char   *msg_name;
  instance_t    instance;
  int           result;
104
#endif
knopp's avatar
   
knopp committed
105
  DCI_PDU *DCI_pdu[MAX_NUM_CCs];
knopp's avatar
   
knopp committed
106
  int CC_id,i,next_i;
knopp's avatar
   
knopp committed
107
  UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list;
108
  rnti_t rnti;
109

110
111
  Protocol__ProgranMessage *msg;

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

114
  start_meas(&eNB_mac_inst[module_idP].eNB_scheduler);
gauthier's avatar
gauthier committed
115
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN);
116

117
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
knopp's avatar
   
knopp committed
118
    DCI_pdu[CC_id] = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu;
119
120
    DCI_pdu[CC_id]->nCCE=0;
    DCI_pdu[CC_id]->num_pdcch_symbols=1;
knopp's avatar
   
knopp committed
121
    mbsfn_status[CC_id]=0;
122
123
    // clear vrb_map
    memset(eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map,0,100);
knopp's avatar
   
knopp committed
124
  }
125

knopp's avatar
   
knopp committed
126
  // refresh UE list based on UEs dropped by PHY in previous subframe
127
128
129
  i = UE_list->head;

  while (i>=0) {
130
131
132
133
    rnti = UE_RNTI(module_idP, i);
    CC_id = UE_PCCID(module_idP, i);
    LOG_D(MAC,"UE %d: rnti %x (%p)\n", i, rnti,
          mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti));
134
    next_i= UE_list->next[i];
135

136
137
    if (mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti)==NULL) {
      mac_remove_ue(module_idP, i, frameP, subframeP);
138
139
140
141
142
143
      //Inform the controller about the UE deactivation. Should be moved to RRC agent in the future
      if (mac_agent_registered[module_idP]) {
	agent_mac_xface[module_idP]->enb_agent_notify_ue_state_change(module_idP,
								      rnti,
								      PROTOCOL__PRP_UE_STATE_CHANGE_TYPE__PRUESC_DEACTIVATED);
      }
144
145
    }
    i = next_i;
knopp's avatar
   
knopp committed
146
  }
147

148
#if defined(ENABLE_ITTI)
149

150
  do {
151
152
    // Checks if a message has been sent to MAC sub-task
    itti_poll_msg (TASK_MAC_ENB, &msg_p);
153

154
155
156
    if (msg_p != NULL) {
      msg_name = ITTI_MSG_NAME (msg_p);
      instance = ITTI_MSG_INSTANCE (msg_p);
157

158
159
160
161
      switch (ITTI_MSG_ID(msg_p)) {
      case MESSAGE_TEST:
        LOG_D(MAC, "Received %s\n", ITTI_MSG_NAME(msg_p));
        break;
162

163
164
165
166
      case RRC_MAC_BCCH_DATA_REQ:
        LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n",
              msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
              RRC_MAC_BCCH_DATA_REQ (msg_p).frame, RRC_MAC_BCCH_DATA_REQ (msg_p).enb_index);
167

168
169
        // TODO process BCCH data req.
        break;
170

171
172
173
174
      case RRC_MAC_CCCH_DATA_REQ:
        LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n",
              msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
              RRC_MAC_CCCH_DATA_REQ (msg_p).frame, RRC_MAC_CCCH_DATA_REQ (msg_p).enb_index);
175

176
177
        // TODO process CCCH data req.
        break;
178
179
180

#ifdef Rel10

181
182
183
184
      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",
              msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
              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);
185

186
187
188
        // TODO process MCCH data req.
        break;
#endif
189

190
191
192
      default:
        LOG_E(MAC, "Received unexpected message %s\n", msg_name);
        break;
gauthier's avatar
gauthier committed
193
      }
194
195
196
197

      result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
      AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
    }
198
  } while(msg_p != NULL);
199

200
201
#endif

gauthier's avatar
gauthier committed
202
  // clear DCI and BCCH contents before scheduling
203
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
knopp's avatar
   
knopp committed
204
205
    DCI_pdu[CC_id]->Num_common_dci  = 0;
    DCI_pdu[CC_id]->Num_ue_spec_dci = 0;
206

207

208
#ifdef Rel10
209
    eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active =0;
210
#endif
211

knopp's avatar
   
knopp committed
212
213
    eNB_mac_inst[module_idP].frame    = frameP;
    eNB_mac_inst[module_idP].subframe = subframeP;
214
215


knopp's avatar
   
knopp committed
216
  }
217
218
219
220
221
  
#ifndef DISABLE_SF_TRIGGER
  //Send subframe trigger to the controller
  if (mac_agent_registered[module_idP]) {
    agent_mac_xface[module_idP]->enb_agent_send_sf_trigger(module_idP);
222
    agent_mac_xface[module_idP]->enb_agent_send_update_mac_stats(module_idP);
223
224
225
  }
#endif
  
gauthier's avatar
gauthier committed
226
  //if (subframeP%5 == 0)
knopp's avatar
   
knopp committed
227
  //#ifdef EXMIMO
228
  PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, 0,module_idP);
229
  pdcp_run(&ctxt);
knopp's avatar
   
knopp committed
230
  //#endif
231

232
  // check HO
233
234
  rrc_rx_tx(&ctxt,
            0, // eNB index, unused in eNB
235
            CC_id);
236
237

#ifdef Rel10
238
239

  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
240
241
242
243
    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);
knopp's avatar
   
knopp committed
244
    }
245
  }
246

247
#endif
knopp's avatar
   
knopp committed
248
  // refresh UE list based on UEs dropped by PHY in previous subframe
249
  /*
knopp's avatar
   
knopp committed
250
251
252
  i=UE_list->head;
  while (i>=0) {
    next_i = UE_list->next[i];
253
    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)));
knopp's avatar
   
knopp committed
254
    if (mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i))==NULL) {
knopp's avatar
   
knopp committed
255
      mac_remove_ue(module_idP,i,frameP);
knopp's avatar
   
knopp committed
256
257
258
    }
    i=next_i;
  }
259
  */
260

gauthier's avatar
gauthier committed
261
  switch (subframeP) {
262
  case 0:
263

264
    // FDD/TDD Schedule Downlink RA transmissions (RA response, Msg4 Contention resolution)
gauthier's avatar
gauthier committed
265
    // Schedule ULSCH for FDD or subframeP 4 (TDD config 0,3,6)
266
    // Schedule Normal DLSCH
gauthier's avatar
gauthier committed
267

knopp's avatar
knopp committed
268

269
270
    schedule_RA(module_idP,frameP,subframeP,2);

271
272

    if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
273
      schedule_ulsch(module_idP,frameP,cooperation_flag,0,4);//,calibration_flag);
274
275
276
    } else if  ((mac_xface->lte_frame_parms->tdd_config == TDD) || //TDD
                (mac_xface->lte_frame_parms->tdd_config == 3) ||
                (mac_xface->lte_frame_parms->tdd_config == 6)) {
277
      //schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4);//,calibration_flag);
Florian Kaltenberger's avatar
Florian Kaltenberger committed
278
    }
279
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
280
281
    schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
    fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
282
283
284
285
286
287
288
289
290
291
#else
    if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
292
	  apply_dl_scheduling_decisions(module_idP,
293
294
295
296
297
298
299
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
300
301
302
    break;

  case 1:
303

gauthier's avatar
gauthier committed
304
    // TDD, schedule UL for subframeP 7 (TDD config 0,1) / subframeP 8 (TDD Config 6)
305
306
    // FDD, schedule normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
307
308
309
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 0:
      case 1:
310
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7);
311
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
312
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
313
#endif
314
315
316
        break;

      case 6:
317
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8);
318
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
319
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
320
#endif
321
322
323
324
325
326
        break;

      default:
        break;
      }
    } else { //FDD
327
      schedule_ulsch(module_idP,frameP,cooperation_flag,1,5);
328
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
329
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
330
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
331
332
333
334
335
336
337
338
339
340
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
341
	  apply_dl_scheduling_decisions(module_idP,
342
343
344
345
346
347
348
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
349
    }
350

351
    break;
352
353

  case 2:
354

gauthier's avatar
gauthier committed
355
    // TDD, nothing
356
357
    // FDD, normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
358
      schedule_ulsch(module_idP,frameP,cooperation_flag,2,6);
359
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
360
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
361
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
362
363
364
365
366
367
368
369
370
371
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
372
	  apply_dl_scheduling_decisions(module_idP,
373
374
375
376
377
378
379
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
380
    }
381

382
383
384
    break;

  case 3:
385

gauthier's avatar
gauthier committed
386
    // TDD Config 2, ULSCH for subframeP 7
387
388
389
    // TDD Config 2/5 normal DLSCH
    // FDD, normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) {
390
391
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 2:
392
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7);
393
394
395

        // no break here!
      case 5:
396
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
397
398
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
399
400
401
402
403
404
405
406
407
408
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
409
	  apply_dl_scheduling_decisions(module_idP,
410
411
412
413
414
415
416
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
417
418
419
420
421
422
        break;

      default:
        break;
      }
    } else { //FDD
423

424
      schedule_ulsch(module_idP,frameP,cooperation_flag,3,7);
425
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
426
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
427
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
428
429
430
431
432
433
434
435
436
437
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
438
	  apply_dl_scheduling_decisions(module_idP,
439
440
441
442
443
444
445
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
446
    }
447

448
    break;
449
450

  case 4:
451

gauthier's avatar
gauthier committed
452
    // TDD Config 1, ULSCH for subframeP 8
453
454
455
    // TDD Config 1/2/4/5 DLSCH
    // FDD UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == 1) { // TDD
456
457
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 1:
458
        //        schedule_RA(module_idP,frameP,subframeP);
459
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8);
460
461
462
463
464
465
466
467
468

        // no break here!
      case 2:

        // no break here!
      case 4:

        // no break here!
      case 5:
469
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
470
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
471
472
473
474
475
476
477
478
479
480
481
	fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
482
	  apply_dl_scheduling_decisions(module_idP,
483
484
485
486
487
488
489
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif	
490
491
492
493
494
495
496
497
        break;

      default:
        break;
      }
    } else {
      if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD

498
499
	//        schedule_RA(module_idP,frameP, subframeP, 0);
	schedule_ulsch(module_idP, frameP, cooperation_flag, 4, 8);
500
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
501
	schedule_ue_spec(module_idP, frameP, subframeP,  mbsfn_status);
502
        fill_DLSCH_dci(module_idP, frameP, subframeP,   mbsfn_status);
503
504
505
506
507
508
509
510
511
512
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
513
	  apply_dl_scheduling_decisions(module_idP,
514
515
516
517
518
519
520
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}     
#endif
521
      }
522
    }
523

524
525
526
527
528
529
530
    break;

  case 5:
    // TDD/FDD Schedule SI
    // TDD Config 0,6 ULSCH for subframes 9,3 resp.
    // TDD normal DLSCH
    // FDD normal UL/DLSCH
531
    schedule_SI(module_idP,frameP,subframeP);
532

533
    //schedule_RA(module_idP,frameP,subframeP,5);
534
    if (mac_xface->lte_frame_parms->frame_type == FDD) {
535
536
      schedule_RA(module_idP,frameP,subframeP,1);
      schedule_ulsch(module_idP,frameP,cooperation_flag,5,9);
537
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
538
539
      schedule_ue_spec(module_idP, frameP, subframeP,  mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
540
541
542
543
544
545
546
547
548
549
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
550
	  apply_dl_scheduling_decisions(module_idP,
551
552
553
554
555
556
557
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
558
559
    } else if ((mac_xface->lte_frame_parms->tdd_config == 0) || // TDD Config 0
               (mac_xface->lte_frame_parms->tdd_config == 6)) { // TDD Config 6
560
      //schedule_ulsch(module_idP,cooperation_flag,subframeP);
561
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
562
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
563
#endif
564
    } else {
565
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
566
567
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
568
569
570
571
572
573
574
575
576
577
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
578
	  apply_dl_scheduling_decisions(module_idP,
579
580
581
582
583
584
585
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
586
    }
587

588
589
590
    break;

  case 6:
591

592
593
594
595
    // 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
596
597
598
599
600
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 0:
        break;

      case 1:
601
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2);
602
        //  schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
603
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
604
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
605
#endif
606
607
608
        break;

      case 6:
609
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3);
610
        //  schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
611
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
612
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
613
#endif
614
615
616
        break;

      case 5:
617
        schedule_RA(module_idP,frameP,subframeP,2);
618
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
619
620
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
621
622
623
624
625
626
627
628
629
630
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
631
	  apply_dl_scheduling_decisions(module_idP,
632
633
634
635
636
637
638
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
639
640
641
642
        break;

      case 3:
      case 4:
643
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
644
645
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
646
647
648
649
650
651
652
653
654
655
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
656
	  apply_dl_scheduling_decisions(module_idP,
657
658
659
660
661
662
663
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
664
665
666
667
668
669
        break;

      default:
        break;
      }
    } else { //FDD
670
      //      schedule_ulsch(module_idP,frameP,cooperation_flag,6,0);
671
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
672
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
673
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
674
675
676
677
678
679
680
681
682
683
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
684
	  apply_dl_scheduling_decisions(module_idP,
685
686
687
688
689
690
691
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
692
    }
693

694
    break;
gauthier's avatar
gauthier committed
695

696
  case 7:
697

698
699
700
    // TDD Config 3,4,5 Normal DLSCH
    // FDD Normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
701
702
703
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 3:
      case 4:
704
        schedule_RA(module_idP,frameP,subframeP,3);  // 3 = Msg3 subframeP, not
705
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
706
707
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
708
709
710
711
712
713
714
715
716
717
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
718
	  apply_dl_scheduling_decisions(module_idP,
719
720
721
722
723
724
725
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
726
727
728
        break;

      case 5:
729
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
730
731
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
732
733
734
735
736
737
738
739
740
741
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
742
	  apply_dl_scheduling_decisions(module_idP,
743
744
745
746
747
748
749
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
750
751
752
753
754
755
        break;

      default:
        break;
      }
    } else { //FDD
756
      //schedule_ulsch(module_idP,frameP,cooperation_flag,7,1);
757
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
758
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
759
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
760
761
762
763
764
765
766
767
768
769
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
770
	  apply_dl_scheduling_decisions(module_idP,
771
772
773
774
775
776
777
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
778
    }
779

780
781
782
    break;

  case 8:
783

gauthier's avatar
gauthier committed
784
    // TDD Config 2,3,4,5 ULSCH for subframeP 2
785
786
787
    //
    // FDD Normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
788
789
790
791
792
793
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 2:
      case 3:
      case 4:
      case 5:

794
        //  schedule_RA(module_idP,subframeP);
795
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2);
796
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
797
798
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
799
800
801
802
803
804
805
806
807
808
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
809
	  apply_dl_scheduling_decisions(module_idP,
810
811
812
813
814
815
816
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
817
818
819
820
821
822
        break;

      default:
        break;
      }
    } else { //FDD
823
      //schedule_ulsch(module_idP,frameP,cooperation_flag,8,2);
824
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
825
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
826
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
827
828
829
830
831
832
833
834
835
836
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
837
	  apply_dl_scheduling_decisions(module_idP,
838
839
840
841
842
843
844
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
845
    }
846

847
848
849
    break;

  case 9:
850

851
852
    // TDD Config 1,3,4,6 ULSCH for subframes 3,3,3,4
    if (mac_xface->lte_frame_parms->frame_type == TDD) {
853
854
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 1:
855
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3);
856
        schedule_RA(module_idP,frameP,subframeP,7);  // 7 = Msg3 subframeP, not
857
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
858
859
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
860
861
862
863
864
865
866
867
868
869
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
870
	  apply_dl_scheduling_decisions(module_idP,
871
872
873
874
875
876
877
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
878
879
880
881
        break;

      case 3:
      case 4:
882
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3);
883
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
884
885
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
886
887
888
889
890
891
892
893
894
895
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
896
	  apply_dl_scheduling_decisions(module_idP,
897
898
899
900
901
902
903
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
904
905
906
        break;

      case 6:
907
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4);
908
        //schedule_RA(module_idP,frameP,subframeP);
909
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
910
911
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
912
913
914
915
916
917
918
919
920
921
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
922
	  apply_dl_scheduling_decisions(module_idP,
923
924
925
926
927
928
929
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
930
931
932
933
        break;

      case 2:
      case 5:
934
        //schedule_RA(module_idP,frameP,subframeP);
935
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
936
937
        schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
938
939
940
941
942
943
944
945
946
947
#else
	if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
948
	  apply_dl_scheduling_decisions(module_idP,
949
950
951
952
953
954
955
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
	}
#endif
956
957
958
959
960
961
        break;

      default:
        break;
      }
    } else { //FDD
962
      //     schedule_ulsch(module_idP,frameP,cooperation_flag,9,3);
963
#ifndef ENABLE_ENB_AGENT_DL_SCHEDULER
964
      schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status);
965
      fill_DLSCH_dci(module_idP,frameP,subframeP,mbsfn_status);
966
967
968
969
970
971
972
973
974
975
#else
      if (mac_agent_registered[module_idP]) {                                  
	  enb_agent_mac_create_empty_dl_config(module_idP, &msg);
	  agent_mac_xface[module_idP]->enb_agent_schedule_ue_spec(
                                                                module_idP,
                                                                frameP,                  
                                                                subframeP,
                                                                mbsfn_status,
                                                                msg);
	  
976
	  apply_dl_scheduling_decisions(module_idP,
977
978
979
980
981
982
983
				     frameP,
				     subframeP,
				     mbsfn_status,
				     msg);
	  enb_agent_mac_destroy_dl_config(msg);
      }
#endif
984
    }
985

986
    break;
gauthier's avatar
gauthier committed
987

988
  }
989

990
  LOG_D(MAC,"FrameP %d, subframeP %d : Scheduling CCEs\n",frameP,subframeP);
991

992
  // Allocate CCEs for good after scheduling is done
993
994
  for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++)
    allocate_CCEs(module_idP,CC_id,subframeP,0);
995

996
  LOG_D(MAC,"frameP %d, subframeP %d\n",frameP,subframeP);
997

998
  stop_meas(&eNB_mac_inst[module_idP].eNB_scheduler);
gauthier's avatar
gauthier committed
999
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT);
1000

1001
}
1002
1003
1004